Spaces:
Runtime error
Runtime error
File size: 952 Bytes
95d4e02 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #!/bin/sh
# Git pre-commit hook: block commits that stage source files without updating README.md + CLAUDE.md.
# Installed to .git/hooks/pre-commit by scripts/install-hooks.sh.
STAGED=$(git diff --cached --name-only)
# Only enforce when at least one source file is changing
SOURCE_CHANGED=$(echo "$STAGED" | grep -E '\.(py|js|html|css)$' | grep -v '^tests/' | head -1)
[ -z "$SOURCE_CHANGED" ] && exit 0
README_STAGED=$(echo "$STAGED" | grep '^README\.md$')
CLAUDE_STAGED=$(echo "$STAGED" | grep '^CLAUDE\.md$')
if [ -z "$README_STAGED" ] || [ -z "$CLAUDE_STAGED" ]; then
echo ""
echo " Commit blocked: source files staged but docs not updated"
echo ""
[ -z "$README_STAGED" ] && echo " • README.md not staged"
[ -z "$CLAUDE_STAGED" ] && echo " • CLAUDE.md not staged"
echo ""
echo " Update both to reflect your changes, git add them, then retry."
echo " Bypass with: git commit --no-verify"
echo ""
exit 1
fi
exit 0
|