Last active
December 3, 2019 00:09
-
-
Save cboddy/67fa8a2a4664a3c0faa1097d15d021e2 to your computer and use it in GitHub Desktop.
pre-commit git hook for python projects to run autopep8 linter
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/bash | |
# run autopep8 linter on any python files that are part of the commit | |
# and modify them in-place to conform to pep8 | |
git diff --cached --name-only | egrep '\.py$' | xargs --no-run-if-empty autopep8 -ri | |
# re-index files staged for commit | |
git diff --cached --name-only | egrep '\.py$'| xargs -l git add |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment