Created
December 10, 2013 21:43
-
-
Save danroberts/7900774 to your computer and use it in GitHub Desktop.
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 | |
# 5:23 PM Friday, October 18, 2013 - Jim Priest | |
# origin script found here: http://python.dzone.com/articles/tips-using-git-pre-commit-hook | |
# Modified with console checks and to ignore commented file | |
FILES_PATTERN='\.(js|coffee)(\..+)?$' | |
FORBIDDEN='ddescribe\|iit\|console\.log' | |
if git diff --cached --name-only | grep -E -q $FILES_PATTERN ; | |
then | |
: | |
else | |
exit 0; | |
fi | |
if git diff --cached --name-only | \ | |
grep -E $FILES_PATTERN | \ | |
xargs grep --with-filename -n $FORBIDDEN; | |
then | |
echo 'COMMIT REJECTED! Found console. references. Please remove them before committing.' | |
exit 1; | |
fi | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment