File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments