Created
December 16, 2020 21:20
-
-
Save drichardson/e51c8f30eda079f732eb42ed95f8e2e1 to your computer and use it in GitHub Desktop.
git pre-commit hook script to run pycodestyle to check for PEP-8 conformance
This file contains hidden or 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/sh | |
# Is pycodestyle is installed? | |
which pycodestyle &> /dev/null | |
if [[ $? -ne 0 ]]; then | |
cat <<-EOF | |
pre-commit hook failed. pycodestyle is not installed. | |
Run the following and try your commit again: | |
pip install pycodestyle | |
EOF | |
exit 1 | |
fi | |
# Run pycodestyle to check pep8 conformance. | |
pycodestyle | |
if [[ $? -ne 0 ]]; then | |
echo pycodestyle failed in pre-commit hook. | |
echo Fix errors and retry commit. | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment