Last active
August 29, 2015 14:00
-
-
Save kunev/11377872 to your computer and use it in GitHub Desktop.
python pre-commit hook
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/sh | |
# 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