atmos git hooks run
Execute the command or ordered steps configured for a Git hook under git.hooks. This is what the .git/hooks/* shims installed by atmos git hooks install invoke, but it can also be run directly — useful for testing a hook without triggering it through Git. Steps run from the repository root, even when you invoke the hook from a subdirectory.
Usage
atmos git hooks run <hook-name> [args...]
Given this configuration:
git:
hooks:
pre-commit:
command: atmos workflow pre-commit
commit-msg:
command: atmos workflow commit-msg -- "$1"
Git invokes the installed shim, which runs:
atmos git hooks run commit-msg .git/COMMIT_EDITMSG
Examples
# Test a hook without committing
atmos git hooks run pre-commit
# Run a hook that takes arguments (commit-msg receives the message file path)
atmos git hooks run commit-msg .git/COMMIT_EDITMSG
Behavior
- Loads the Atmos configuration for the current repository and selects the hook's
commandorsteps. - Runs
stepsin order through the registered step library, from the repository root even when invoked from a subdirectory. The step metrics summary is off by default for hooks. Embedded Starlark runs inside Atmos; a failed step stops the hook. Hook arguments are available asctx.argsin Starlark steps and as$1,"$@", andATMOS_GIT_HOOK_ARGSin shell steps. - Runs
commandhooks through the shared shell runner with the inherited process environment, includingPATH. Prepare any tools or identity credentials before invoking the hook. - Forwards hook arguments and stdin to
commandhooks — hooks such aspre-pushandpre-receivereceive their input on stdin, not argv. Forstepshooks, Atmos saves the data Git pipes topre-push,pre-receive,post-receive,post-rewrite,reference-transaction, andproc-receiveto a temporary file whose path is inATMOS_GIT_HOOK_STDIN, and the first shell step also receives the data on its standard input. Atmos removes the file when the hook ends. - Propagates the command's exit code, so a failing hook command blocks the Git operation exactly as a hand-written hook would. For
stepshooks the exit code is the failing step's: a Starlarkfail()exits with 1, anderrors.build("message").with_exit_code(5).fail()exits with 5. - Fails a prompt step that has no
default:when the hook runs without a terminal, with a hint that settingdefault:lets the step run there. - Lets a later configuration source replace an earlier hook definition: switching a hook between
steps:andcommand:replaces the earlier form. - Fails with a clear error listing the configured hooks when
<hook-name>is not configured undergit.hooks.
Arguments
hook-name(required)The Git hook to run, matching a key under
git.hooks(pre-commit,commit-msg,pre-push, ...).args...(optional)Arguments forwarded verbatim to the configured command — exactly what Git passes to the hook (for example, the commit message file path for
commit-msg). Arguments are passed through even when they look like flags.
Related
atmos git hooks install— install the shims that call this command- Workflows — what hook commands typically invoke
- Git Configuration — the
git.hookssection
For inline scripts and execution details, see Git hook steps.