Last active
September 6, 2016 11:07
-
-
Save julien-duponchelle/5786a7bf0e9e9a6a8b20 to your computer and use it in GitHub Desktop.
Git PEP 8 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/bash | |
echo "Pre-commit started" | |
echo "PEP 8" | |
git diff --cached --name-only | grep .py | grep -v old_ | xargs autopep8 --in-place -v --aggressive --aggressive | |
git diff --cached --name-only | grep .py | grep -v old_ | xargs git add | |
git diff --cached --name-only | grep .py | grep -v old_ | xargs pep8 | |
if [ $? == 0 ] | |
then | |
exit 0 | |
fi | |
# Allows us to read user input below, assigns stdin to keyboard | |
exec < /dev/tty | |
echo "Do you want to ignore warning?" | |
select yn in "Yes" "No"; do | |
case $yn in | |
Yes ) exit 0;; | |
No ) exit 1;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment