-
-
Save akhiljalagam/752feea3aa6b465679aa658af5d2ffa2 to your computer and use it in GitHub Desktop.
Python pre-commit hook
This file contains hidden or 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