feat(gitflow): hooks in every repo, no per-project step
Global: `make link` generates githooks/ from lib/gitflow.sh and sets git's global core.hooksPath to ~/.claude/githooks, so every repo on the machine runs the pre-commit protection and the post-commit / post-merge push, even one that never ran gitflow init. A repo's own local core.hooksPath still wins, so hooks/session-start.sh calls `gitflow reconcile-hooks` once per session and rewrites a .githooks/ that lags the lib (LRN-114 automated); the pre-commit exemption now covers .githooks/** next to .claude/**. Per-repo opt-outs for a foreign clone: `git config gitflow.protect false` (branch model) and `git config gitflow.autopush false` (push). Both, and the GIT_CONFIG_GLOBAL= / GIT_CONFIG= env bypass, are static deny rules. `make test` and the two suites that commit on main export GIT_CONFIG_GLOBAL=/dev/null so the machine's global hooks never fire in throwaway repos. doctor gains "Git hooks" (global setting, githooks/ equal to the emitters) and "Scratchpad" (warn when TMPDIR sits on a tmpfs with usrquota: systemd caps each user at 80% of it, which killed two shells today, BLK-021). Tests: T18h, T19d, T20 (reconcile), T21 (whitelist and protect opt-out); this repo's own stale .githooks/ refreshed.
This commit is contained in:
@@ -20,7 +20,26 @@ link_file() {
|
||||
link_file "$REPO/CLAUDE.global.md" "$CLAUDE/CLAUDE.md"
|
||||
link_file "$REPO/settings.json" "$CLAUDE/settings.json"
|
||||
|
||||
for item in hooks agents skills lib templates rules; do
|
||||
# Global git hooks (BDR-095): githooks/ is generated from lib/gitflow.sh so it
|
||||
# never drifts from the per-repo .githooks/ the lib writes, and git's GLOBAL
|
||||
# core.hooksPath points at ~/.claude/githooks → every repo on this machine is
|
||||
# protected and auto-pushed, even one that never ran gitflow init. A repo's
|
||||
# own local core.hooksPath still wins (git precedence), which is what the
|
||||
# session-start reconcile is for.
|
||||
# The tilde is stored literally on purpose: git expands `~` in core.hooksPath
|
||||
# itself, so the setting stays valid on any machine and for any HOME.
|
||||
# shellcheck disable=SC2088
|
||||
_gh_before=$(git config --global core.hooksPath 2>/dev/null || true)
|
||||
# shellcheck disable=SC2088
|
||||
bash "$REPO/lib/gitflow.sh" global-hooks "$REPO/githooks" '~/.claude/githooks'
|
||||
# shellcheck disable=SC2088
|
||||
if [ "$_gh_before" != '~/.claude/githooks' ]; then
|
||||
echo "🪝 git config --global core.hooksPath ~/.claude/githooks (was: ${_gh_before:-unset})"
|
||||
CHANGED=$((CHANGED + 1))
|
||||
fi
|
||||
unset _gh_before
|
||||
|
||||
for item in hooks githooks agents skills lib templates rules; do
|
||||
target="$CLAUDE/$item"
|
||||
if [ -L "$target" ]; then
|
||||
if [ "$(readlink "$target")" = "$REPO/$item" ]; then
|
||||
|
||||
Reference in New Issue
Block a user