Skip to content

Instantly share code, notes, and snippets.

@pbu88
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbu88/5a510b245bb81ac1fd64 to your computer and use it in GitHub Desktop.
Save pbu88/5a510b245bb81ac1fd64 to your computer and use it in GitHub Desktop.
pre-commit hook to search for debugging statements.
#!/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