Skip to content

Instantly share code, notes, and snippets.

@conformist-mw
Created September 15, 2017 11:36
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 conformist-mw/ae08a39db1cb76cbf762ce35b0d02087 to your computer and use it in GitHub Desktop.
Save conformist-mw/ae08a39db1cb76cbf762ce35b0d02087 to your computer and use it in GitHub Desktop.
#!/bin/bash
# How to use this script:
# $ git config --global init.templatedir '~/.git-templates'
# $ mkdir -p ~/.git-templates/hooks
# save this file as pre-commit
# $ chmod +x ~/.git-templates/hooks/pre-commit
RED=`tput setaf 1`
GREEN=`tput setaf 2`
RESET=`tput sgr0`
FILES=`find . -iname '*.py'`
for file in $FILES; do
if egrep -A1 -i '#\s*todo|debug|dbg' $file | grep -q 'print'; then
printf "remove ${RED}debug print${RESET} or run ${GREEN}git commit --no-verify${RESET}\n"
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment