Skip to content

Instantly share code, notes, and snippets.

@tkaemming
Created December 7, 2011 06:36
Show Gist options
  • Save tkaemming/1441732 to your computer and use it in GitHub Desktop.
Save tkaemming/1441732 to your computer and use it in GitHub Desktop.
bash pre-commit script to run pyflakes and pep8 checks
#!/bin/bash
ERROR_LIST=$(find . -name \*.py -not -path \*migrations/\* -not -path \*settings/\* -not -path \*vendor/\* -not -path \*node_modules/\* | xargs pyflakes)
RETVAL=$?
if [[ $RETVAL -ne 0 ]]; then
echo "Encountered errors during pyflakes check, cowardly refusing to commit."
echo "$ERROR_LIST"
exit $RETVAL
fi
ERROR_LIST="$(pep8 -r --show-source --ignore=W391 --exclude=migrations/,vendor/,node_modules/ .)"
RETVAL=$?
if [[ $RETVAL -ne 0 ]]; then
echo "Encountered errors during PEP8 style check, cowardly refusing to commit."
echo "$ERROR_LIST"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment