Skip to content

Instantly share code, notes, and snippets.

@breard-r
Last active July 25, 2016 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save breard-r/f34b68778e6753c87022 to your computer and use it in GitHub Desktop.
Save breard-r/f34b68778e6753c87022 to your computer and use it in GitHub Desktop.
PEP8 compliance pre-commit git hook
#!/bin/sh
# Inline version:
# find . -wholename "./*/migrations" -prune -o -wholename "./docs/*" -prune -o -name "*\.py" -exec pep8 {} \;
final_exit=0
for file in $(find . -wholename "./*/migrations" -prune -o -wholename "./docs/*" -prune -o -name "*\.py" -print); do
pep8 "$file"
if [ $? -ne 0 ]; then
final_exit=1
fi
done
if [ $final_exit -ne 0 ]; then
echo "PEP8 compliance test failed, aborting commit."
fi
exit $final_exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment