branch: elpa/datetime
commit 512784d235fe0ae64b4a9bfedba990f5900ebf04
Author: Paul Pogonyshev <pogonys...@gmail.com>
Commit: Paul Pogonyshev <pogonys...@gmail.com>

    Add more Git hooks.
---
 githooks/pre-commit | 11 +++++++++--
 githooks/pre-push   | 10 ++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/githooks/pre-commit b/githooks/pre-commit
index 3efc31e9e5..2bb549d4c5 100755
--- a/githooks/pre-commit
+++ b/githooks/pre-commit
@@ -1,9 +1,16 @@
 #!/bin/sh
 
+DISCLAIMER="Remember that you can ignore these checks and force-commit with 
'git commit -n'"
+
 # This can be used in a comment as a reminder to self.
 git diff-index --cached -S "DONOTCOMMIT" HEAD --patch --exit-code ":!githooks" 
\
-    || { echo; echo "Have you forgotten about the “DONOTCOMMIT”?"; exit 1; }
+    || { echo; echo "Have you forgotten about the “DONOTCOMMIT”?"; echo 
$DISCLAIMER; exit 1; }
+
+git diff-index --cached                  HEAD -u . \
+    | egrep -C3 "^-.*DONOTCHANGETHIS" \
+    && { echo "There is a changed line with DONOTCHANGETHIS in it"; echo 
$DISCLAIMER; exit 1; } \
+    || true
 
 # Eldev functions can be used during development, but must not be committed.
 git diff-index --cached -S "eldev-" HEAD --patch --exit-code ":!githooks" 
":!Eldev" \
-    || { echo; echo "Don't commit code relying on Eldev!"; exit 1; }
+    || { echo; echo "Don't commit code relying on Eldev!"; echo $DISCLAIMER; 
exit 1; }
diff --git a/githooks/pre-push b/githooks/pre-push
new file mode 100644
index 0000000000..b5307f437a
--- /dev/null
+++ b/githooks/pre-push
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+DISCLAIMER="Remember that you can ignore these checks and force-push with 'git 
push --no-verify'"
+
+REMOTE=$1
+
+git log "$REMOTE/HEAD..HEAD" \
+    | egrep -C5 "DONOTPUSH" \
+    && { echo "There is a not-yet-pushed commit with DONOTPUSH in its 
message"; echo $DISCLAIMER; exit 1; } \
+    || true

Reply via email to