PEP 8 Git pre commit hook
in Python
This pre commit hook will check the PEP8 syntax of your Python files and ask you if you want to continue the commit process.
In your project directory create a file: .git/hooks/pre-commit and add the execution permission on it.
#!/bin/bash echo "Pre-commit started" echo "PEP 8 check" git diff --cached --name-only | grep .py | 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?