Last active
August 29, 2015 14:07
-
-
Save pbu88/5a510b245bb81ac1fd64 to your computer and use it in GitHub Desktop.
pre-commit hook to search for debugging statements.
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/bash | |
# This pre-commit hook will look for statements such as | |
# import pdb; and console.log; and if found it will prevent | |
# the commit from succeed. | |
declare -a REGEXS=("^+.*import pdb;" "^+.*console.log" "^+.*debugger;" "^+.*var_dump") | |
for re in "${REGEXS[@]}" | |
do | |
RES=`git diff --cached HEAD | grep "$re"` | |
if [ -n "$RES" ]; then | |
printf "\033[0;31mFATAL:\033[00m Found regex \033[0;32m$re\33[00m in staged changes\n" | |
exit 1 | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment