Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.