forked from bchanot/claude
fix(gitflow): pre-commit exempts only .claude memory, tasks, audits, deploy
Any .claude/** set passed on main/develop, rules and settings included, and a git mv hid its source. The hook now allowlists the side-car dirs and lists with --no-renames; both hook copies regenerated, citers reworded.
This commit is contained in:
1 parent
97c6afcbc8
commit
c5bd0f8312
7 files changed
+51
-21
No files matched your search
@@ -32,8 +32,8 @@ doc reconciliation & curation skills (+ `/refactor`), run OUTSIDE an assistance
|
||||
`/bugfix` `/hotfix` `/ship-feature` a working branch already exists (this check
|
||||
returns WORKING) and the memory commit rides it. The aiguillage only fires when
|
||||
such a skill is invoked directly on `main`/`develop` — i.e. memory IS the work,
|
||||
with no code branch to follow. That is the leak it closes: the `.claude/**` hook
|
||||
exemption still lets a *manual* memory commit through on a protected base, but a
|
||||
with no code branch to follow. That is the leak it closes: the `.claude/` allowlist hook exemption
|
||||
still lets a *manual* memory commit through on a protected base, but a
|
||||
skill-driven one now branches to `chore/*` first.
|
||||
|
||||
**Integration is human-gated by default** — these flows commit, they do not merge.
|
||||
|
||||
+24
-1
@@ -89,7 +89,7 @@ echo x >> README.md; git add README.md
|
||||
chk "block direct code on main" '! git commit -q -m onmain 2>/dev/null'
|
||||
git restore --staged README.md 2>/dev/null; git checkout -q -- README.md
|
||||
mkdir -p .claude/memory; echo m > .claude/memory/decisions.md; git add .claude/memory/decisions.md
|
||||
chk "allow .claude/** on main" 'git commit -q -m "chore(memory)" 2>/dev/null'
|
||||
chk "allow .claude/memory on main" 'git commit -q -m "chore(memory)" 2>/dev/null'
|
||||
gitflow_start feature demo >/dev/null 2>&1
|
||||
echo f > feat.txt; git add feat.txt
|
||||
chk "allow code on feature" 'git commit -q -m "feat work" 2>/dev/null'
|
||||
@@ -474,6 +474,29 @@ git config gitflow.protect false
|
||||
chk "T21c gitflow.protect=false → allowed" '.githooks/pre-commit 2>/dev/null'
|
||||
git config --unset gitflow.protect
|
||||
git restore --staged code.txt .githooks/post-merge 2>/dev/null || true
|
||||
git reset -q; rm -f code.txt
|
||||
# allowlist (memory, tasks, audits, deploy, .githooks): any other .claude/ path blocks
|
||||
mkdir -p .claude/rules .claude/tasks .claude/memory .claude/audits .claude/deploy
|
||||
echo r > .claude/rules/x.md; echo '{}' > .claude/settings.json
|
||||
git add .claude/rules/x.md; git -c core.hooksPath=/dev/null commit -q -m "seed rules"
|
||||
echo r2 >> .claude/rules/x.md; git add .claude/rules/x.md
|
||||
chk "T21d .claude/rules-only on develop → blocked" '! .githooks/pre-commit 2>/dev/null'
|
||||
git reset -q; git checkout -q -- .claude/rules/x.md
|
||||
git add .claude/settings.json
|
||||
chk "T21e .claude/settings.json-only on develop → blocked" '! .githooks/pre-commit 2>/dev/null'
|
||||
git reset -q
|
||||
git mv .claude/rules/x.md .claude/tasks/x.md
|
||||
chk "T21f rename rules→tasks on develop → blocked (--no-renames)" '! .githooks/pre-commit 2>/dev/null'
|
||||
git reset -q --hard
|
||||
for d in memory tasks audits deploy; do
|
||||
echo "$d" > ".claude/$d/n.md"; git add ".claude/$d/n.md"
|
||||
chk "T21g .claude/$d-only on develop → allowed" '.githooks/pre-commit 2>/dev/null'
|
||||
git reset -q
|
||||
done
|
||||
echo m > .claude/memory/n.md; echo r3 >> .claude/rules/x.md
|
||||
git add .claude/memory/n.md .claude/rules/x.md
|
||||
chk "T21h memory + rules mix on develop → blocked" '! .githooks/pre-commit 2>/dev/null'
|
||||
git reset -q --hard
|
||||
|
||||
echo "T22 — delete guard: never main/develop, never unmerged (premise: -d is dead once the upstream is in sync)"
|
||||
newrepo delguard; echo a>a; hookon; gitflow_init >/dev/null 2>&1
|
||||
|
||||
+6
-4
@@ -485,15 +485,17 @@ case "\$br" in
|
||||
*) exit 0 ;; # working branch — allow
|
||||
esac
|
||||
|
||||
# whitelist: all-staged-under-.claude/ (memory/doc/deploy helpers) or
|
||||
# .githooks/ (the hooks themselves, refreshed by the lib) — allow
|
||||
if [ -z "\$(git diff --cached --name-only | grep -vE '^\.(claude|githooks)/' | head -1)" ]; then
|
||||
# whitelist: every staged path under .claude/{memory,tasks,audits,deploy}/ or
|
||||
# .githooks/ (memory/doc/deploy helpers, the hooks themselves) — allow. Rules,
|
||||
# settings, agents, skills stay blocked. --no-renames lists a rename's source
|
||||
# too, so a git mv out of a blocked path cannot hide.
|
||||
if [ -z "\$(git diff --cached --name-only --no-renames | grep -vE '^(\.claude/(memory|tasks|audits|deploy)|\.githooks)/' | head -1)" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "gitflow pre-commit: BLOCKED — direct commit on '\$br'." >&2
|
||||
echo " Branch from the right base (feature/bugfix->develop, hotfix->main), or merge." >&2
|
||||
echo " (.claude/** and .githooks/** commits are exempt; foreign clone? git config gitflow.protect false)" >&2
|
||||
echo " (.claude/{memory,tasks,audits,deploy}/ and .githooks/ commits are exempt; foreign clone? git config gitflow.protect false)" >&2
|
||||
exit 1
|
||||
HOOK
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user