Skip to content

Commit 512784d

Browse files
committed
Add more Git hooks.
1 parent ca27cf4 commit 512784d

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

githooks/pre-commit

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/bin/sh
22

3+
DISCLAIMER="Remember that you can ignore these checks and force-commit with 'git commit -n'"
4+
35
# This can be used in a comment as a reminder to self.
46
git diff-index --cached -S "DONOTCOMMIT" HEAD --patch --exit-code ":!githooks" \
5-
|| { echo; echo "Have you forgotten about the “DONOTCOMMIT”?"; exit 1; }
7+
|| { echo; echo "Have you forgotten about the “DONOTCOMMIT”?"; echo $DISCLAIMER; exit 1; }
8+
9+
git diff-index --cached HEAD -u . \
10+
| egrep -C3 "^-.*DONOTCHANGETHIS" \
11+
&& { echo "There is a changed line with DONOTCHANGETHIS in it"; echo $DISCLAIMER; exit 1; } \
12+
|| true
613

714
# Eldev functions can be used during development, but must not be committed.
815
git diff-index --cached -S "eldev-" HEAD --patch --exit-code ":!githooks" ":!Eldev" \
9-
|| { echo; echo "Don't commit code relying on Eldev!"; exit 1; }
16+
|| { echo; echo "Don't commit code relying on Eldev!"; echo $DISCLAIMER; exit 1; }

githooks/pre-push

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
DISCLAIMER="Remember that you can ignore these checks and force-push with 'git push --no-verify'"
4+
5+
REMOTE=$1
6+
7+
git log "$REMOTE/HEAD..HEAD" \
8+
| egrep -C5 "DONOTPUSH" \
9+
&& { echo "There is a not-yet-pushed commit with DONOTPUSH in its message"; echo $DISCLAIMER; exit 1; } \
10+
|| true

0 commit comments

Comments
 (0)