Skip to content

Instantly share code, notes, and snippets.

@kunev kunev/pre-commit

Last active Aug 29, 2015
What would you like to do?
python pre-commit hook
# Get all the python files staged for committing
py_files=`git diff --name-only HEAD|grep '.py$'`
# If we;re trying to commit a pdb.set_trace() display an error message and exit right away with status 1
grep -n 'pdb.set_trace()' $py_files && echo -e "\033[1;31m Debugger statements!!!\033[0m" && exit 1
# Run pyflakes on all the files beign committed and exit with status 0 if there are no errors, else show error message
pyflakes $py_files && exit || echo -e "\033[1;31m Lint error!\033[0m"
# If we’re here, then pyflakes failed, exit with status 1
exit 1
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.