Skip to content

Instantly share code, notes, and snippets.

@muke5hy
Forked from breard-r/pre-commit.sh
Created July 25, 2016 14:20
Show Gist options
  • Select an option

  • Save muke5hy/8259cffe13411dc3d199bca2c8d6debd to your computer and use it in GitHub Desktop.

Select an option

Save muke5hy/8259cffe13411dc3d199bca2c8d6debd 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