Commit spec
commit_spec
Shared commit plumbing: spec validation, autofix-retry, result building.
Single source of truth for the commit helpers used by both surfaces
(:class:axm_git.tools.commit.GitCommitTool and
:class:axm_git.hooks.commit_phase.CommitPhaseHook). The validation is
pure (returns (spec, err)) so each surface wraps the error string in
its own result type; the autofix-retry and HookResult builder are shared
verbatim.
AutofixRetry
dataclass
Outcome of an autofix-aware commit retry.
Attributes:
| Name | Type | Description |
|---|---|---|
result |
_GitResultLike
|
The final GitResult-like object (returncode/stdout/stderr). |
retried |
bool
|
Whether a re-stage + retry was actually performed. |
auto_fixed |
list[str]
|
Files the pre-commit hook modified, captured before
re-staging (the subsequent |
Source code in packages/axm-git/src/axm_git/core/commit_spec.py
attempt_commit_with_autofix_retry(cmd, files, git_root, first_result, *, working_dir=None)
Re-stage + retry cmd once when a pre-commit hook auto-fixed files.
Detection is on the combined stdout+stderr of first_result: when the
canonical "files were modified" marker is present, the modified
files are captured (git diff --name-only before re-staging), the
spec files are re-staged via the subdir-aware resolver, and cmd is
retried once. Otherwise first_result is returned unchanged.
Source code in packages/axm-git/src/axm_git/core/commit_spec.py
build_commit_result(git_root, message, identity, warnings)
Build a successful commit :class:HookResult.
Reads the current HEAD short hash and assembles the result dict with optional identity and warning fields.
Source code in packages/axm-git/src/axm_git/core/commit_spec.py
retry_commit_on_autofix(files, cmd, git_root, first_result, *, working_dir=None)
Hook-facing wrapper: return only the retried GitResult.
Thin adapter over :func:attempt_commit_with_autofix_retry for callers
that only need the final result object (the commit-phase hook).
Source code in packages/axm-git/src/axm_git/core/commit_spec.py
validate_commit_spec(spec)
Validate a commit_spec dict (pure; stricter merged contract).
Requires a non-empty message AND a non-empty files list — the
stricter of the two prior per-surface validators. Returns
(spec, error_message) where spec is None when an error is set;
each surface wraps the error string in its own result type.