fix(agents): chain AGENTS git hooks to global core.hooksPath
The local core.hooksPath override set by agents-init shadowed the user's global hooks (ggshield, Git LFS) since git honors only one hooksPath. Each shim now execs the global/system hook of the same name after running version-bump, so global hooks still run after version increment. Bumped the agents-tools version marker to 2 so existing AGENTS repos refresh.
This commit is contained in:
@@ -1,7 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# agents-tools-version: 1
|
||||
# Delegates to the repo's committed .agents-tools/version-bump. Guarded so a
|
||||
# missing script or failed rev-parse never blocks the commit (always exit 0).
|
||||
# agents-tools-version: 2
|
||||
# Runs the committed .agents-tools/version-bump, then chains to the user's
|
||||
# global/system git hook (core.hooksPath) so any global prepare-commit-msg
|
||||
# still runs. agents-init's local core.hooksPath override would otherwise
|
||||
# shadow it. Guarded so a missing script or failed rev-parse never blocks the
|
||||
# commit; only the chained global hook can fail it.
|
||||
root="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
|
||||
[ -x "$root/.agents-tools/version-bump" ] && "$root/.agents-tools/version-bump" prepmsg "$1"
|
||||
|
||||
# Chain to the global/system hook this local override is shadowing.
|
||||
global_hooks="$(git config --global core.hooksPath 2>/dev/null)"
|
||||
[ -z "$global_hooks" ] && global_hooks="$(git config --system core.hooksPath 2>/dev/null)"
|
||||
if [ -n "$global_hooks" ]; then
|
||||
global_hooks="${global_hooks/#\~/$HOME}" # git stores ~ verbatim
|
||||
[ -x "$global_hooks/prepare-commit-msg" ] && exec "$global_hooks/prepare-commit-msg" "$@"
|
||||
fi
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user