Created
September 15, 2017 11:41
-
-
Save conformist-mw/6af01f5788e837bba6cc34e213a7a53c 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/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 | |
# Now if you create new repo or use existing one just init (git init) | |
# and hook will be available. | |
# REMEMBER `git init` DOESN'T wipe out existing repository, only re-init. | |
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