Created
October 7, 2012 19:24
-
-
Save milancermak/3849310 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 | |
# make sure requirements.txt is up to date with every commit | |
# by comparing the output of pip freeze | |
pip freeze | diff requirements.txt - > /dev/null | |
if [ $? != 0 ] | |
then | |
echo "Missing python module dependencies in requirements.txt. Run 'pip freeze > requirements.txt' to update." | |
exit 1 | |
fi | |
# run pyflakes on all the python source files in the repo | |
FAULTS=$(find ./* -iname "*.py" -exec pyflakes {} \; 2>&1 | grep -c -v "undefined name '_'") | |
if [ $FAULTS != 0 ] | |
then | |
find ./* -iname "*.py" -exec pyflakes {} \; 2>&1 | grep -v "undefined name '_'" | |
#exit 1 | |
fi | |
# check for forgotten set_trace() | |
grep -n 'set_trace()' `find ./* -iname '*.py'` && exit 1 || exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it somehow to add this to a .pre-commit-config.yaml file by referencing it or do I have to copy the file into my repository?