Advertisement
shared_prophet

git nocheckin pre-commit hook

Aug 22nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.37 KB | None | 0 0
  1. #!/bin/sh
  2. # Prevent commit if diff contains "NOCHECKIN"
  3.  
  4. if git rev-parse --verify HEAD >/dev/null 2>&1
  5. then
  6.     against=HEAD
  7. else
  8.     # Initial commit: diff against an empty tree object
  9.     against=$(git hash-object -t tree /dev/null)
  10. fi
  11.  
  12. # Redirect output to stderr.
  13. exec 1>&2
  14.  
  15. git diff --name-only $against | xargs grep -iH nocheckin
  16. if [[ $? ]]; then
  17.     exit 1
  18. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement