Created
September 24, 2012 18:07
-
-
Save dcvezzani/3777359 to your computer and use it in GitHub Desktop.
pre-commit hook for Git on a system running OSX (Mac)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if git rev-parse --verify HEAD >/dev/null 2>&1; then | |
against=HEAD | |
else | |
# put the first changeset hash value in your project here (I think) | |
against=facf87a3fa1c853a7dd8dde8cba32e1fc8fde3ea | |
fi | |
for FILE in `git diff-index --name-status $against -- | cut -c3-` ; do | |
# Check if the file contains 'debugger' | |
if [ "grep 'debugger' $FILE" ] | |
then | |
echo $FILE ' contains debugger!' | |
exit 1 | |
fi | |
done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On my system,
if [ "grep 'debugger' $FILE" ]
always evaluates to true. Changing it toif grep -q 'debugger' "$FILE"
fixes that.