Files
fish-config/scripts/agents-tools/hooks/prepare-commit-msg
T
rootiest c3e39b7a96 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.
2026-06-17 22:39:18 -04:00

19 lines
981 B
Bash
Executable File

#!/usr/bin/env bash
# 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