PEP-181: the live-copy pre-commit hook blocks only the live copy itself — worktrees share the hooks directory and kept failing to commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fd87c6780f
commit
d2903db557
@ -46,13 +46,16 @@ REPO="${GITEA_PLATFORM_REPO:-peppa/peppa}"
|
||||
|
||||
# The live copy refuses commits from now on (agents must work in worktrees).
|
||||
HOOK="$(git rev-parse --git-path hooks)/pre-commit"
|
||||
if ! grep -q "PEP-172" "$HOOK" 2>/dev/null; then
|
||||
if ! grep -q "PEP-172/182" "$HOOK" 2>/dev/null; then
|
||||
mkdir -p "$(dirname "$HOOK")"
|
||||
cat >"$HOOK" <<'H'
|
||||
#!/bin/sh
|
||||
# PEP-172: this is the copy the live site runs from — no commits here. Work in a worktree:
|
||||
# git worktree add ~/.peppa/worktrees/peppa/<name> -b task/<key> origin/main
|
||||
# PEP-172/182: this repository's own working copy is the one the live site runs from — no commits
|
||||
# there. Worktrees (agents, coordinator) share this hooks directory and must keep committing.
|
||||
[ -n "$PEPPA_LIVE_COMMIT_OK" ] && exit 0
|
||||
top=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
live=$(cd "$(git rev-parse --git-common-dir)/.." && pwd -P)
|
||||
[ "$(cd "$top" && pwd -P)" = "$live" ] || exit 0
|
||||
echo "Peppa FACTORY: в этой копии работает живой сайт — коммиты здесь запрещены. Работайте в git worktree." >&2
|
||||
exit 1
|
||||
H
|
||||
|
||||
Loading…
Reference in New Issue
Block a user