Commit phase
commit_phase
Commit-phase hook action.
Stages all changes and commits with [axm] {phase_name}.
Supports a from_outputs mode that reads commit_spec
from context for targeted file staging.
CommitPhaseHook
dataclass
Commit all changes with message [axm] {phase_name}.
Reads phase_name from context. An optional
message_format can be provided via params
(default "[axm] {phase}"). Skips gracefully when
there is nothing to commit or no git repository.
When from_outputs=True is passed in params, reads
commit_spec from context instead: {message, body?, files}.
Only the listed files are staged (no git add -A).
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
| Python | |
|---|---|
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | |
commit_from_outputs(context, working_dir, *, skip_hooks=False, profile=None)
Outputs mode: read commit_spec from context, stage listed files.
Resolves the author identity via :func:resolve_identity and
injects --author into the commit command when a profile is
found. If the commit fails because pre-commit hooks auto-fixed
files (stderr contains "files were modified"), the listed
files are re-staged and the commit is retried once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context containing |
required |
working_dir
|
Path
|
Repository working directory. |
required |
skip_hooks
|
bool
|
When True, append |
False
|
profile
|
str | None
|
Optional identity profile name override. |
None
|
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, object]
|
Session context dictionary. |
required |
**params
|
object
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
build_commit_cmd(message, body, *, skip_hooks=True, author=None)
Build the git commit argument list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Commit summary line. |
required |
body
|
str | None
|
Optional extended commit body. |
required |
skip_hooks
|
bool
|
Append |
True
|
author
|
str | None
|
Git |
None
|
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.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/hooks/commit_phase.py
retry_commit_on_autofix(files, cmd, git_root, first_result, *, working_dir=None)
Handle pre-commit autofix retry for a failed commit.
If first_result stderr contains "files were modified", re-stage
files (using the same dual-resolution as the original staging) and
retry the commit once. Otherwise return first_result unchanged.
Returns a GitResult-like object (has returncode, stdout, stderr).
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
stage_spec_files(files, git_root, *, working_dir=None, warnings=None)
Stage each file in files, returning an error message on failure.
Paths in files are resolved against git_root first, then against working_dir (if provided and distinct), so both git-root-relative and package-relative inputs work transparently. Absolute inputs are accepted when they point inside git_root.
Tracked-but-deleted files (git status D) are staged as deletions.
Gitignored files are skipped with a warning appended to warnings.
Truly missing files (never tracked) produce a clear diagnostic error
listing every absolute path that was attempted.