Created
May 23, 2014 23:01
-
-
Save pmclanahan/dae038bc2a5870907efd to your computer and use it in GitHub Desktop.
Flake8 and jshint pre-commit git 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/sh | |
exit_code=0 | |
for file in `git diff --cached --name-only --diff-filter=ACM | sort | uniq` | |
do | |
if [ ${file: -3} == ".py" ]; then | |
flake8 --ignore=E121,E123,E124,E125,E126,E127,E128,E501 $file | |
if [ "$?" -ne "0" ]; then | |
exit_code=1 | |
fi | |
fi | |
if [ ${file: -3} == ".js" ]; then | |
jshint $file | |
if [ "$?" -ne "0" ]; then | |
exit_code=1 | |
fi | |
fi | |
done | |
if [ "$exit_code" -ne "0" ]; then | |
echo "Aborting commit. Fix above errors or do 'git commit --no-verify'." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I also have baked in there for python files to check import order, but its pretty much the same.