Skip to content

Commit 8d92079

Browse files
committed
Add pre-push hook: blocks push if REVISION-HISTORY.md not updated
Install: cp hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push Bypass: git push --no-verify
1 parent 44412ee commit 8d92079

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

hooks/pre-push

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# pre-push hook: block push if tutorial files changed without REVISION-HISTORY.md update
3+
# Install: cp hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push
4+
5+
REMOTE="$1"
6+
RANGE=$(git merge-base HEAD origin/main)..HEAD
7+
8+
# Find tutorial directories with changes (excluding REVISION-HISTORY itself)
9+
CHANGED_TUTS=$(git diff --name-only "$RANGE" -- 'tuts/' | grep -v REVISION-HISTORY | sed 's|tuts/\([^/]*\)/.*|\1|' | sort -u)
10+
11+
MISSING=""
12+
for tut in $CHANGED_TUTS; do
13+
if ! git diff --name-only "$RANGE" -- "tuts/$tut/REVISION-HISTORY.md" | grep -q .; then
14+
MISSING="$MISSING tuts/$tut/REVISION-HISTORY.md\n"
15+
fi
16+
done
17+
18+
if [ -n "$MISSING" ]; then
19+
echo ""
20+
echo "ERROR: Tutorial files changed without updating REVISION-HISTORY.md:"
21+
echo -e "$MISSING"
22+
echo "Update the revision history before pushing (AGENTS.md rule 7)."
23+
echo "To bypass: git push --no-verify"
24+
exit 1
25+
fi

0 commit comments

Comments
 (0)