Last active
December 21, 2015 11:25
-
-
Save hughes/aa511db78d534f9f1c53 to your computer and use it in GitHub Desktop.
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 | |
if [ -n $VIRTUAL_ENV ]; then | |
PATH=$VIRTUAL_ENV/bin:$PATH | |
fi | |
REPO=$(pwd) | |
EXIT_CODE=0 | |
for FILE in `git diff-index --name-only --cached HEAD -- | egrep .js$`; do | |
jshint ${REPO}/${FILE} | |
EXIT_CODE=$((${EXIT_CODE} + $?)) | |
done | |
if [[ ${EXIT_CODE} -ne 0 ]]; then | |
echo "Aborted due to JSHint errors." | |
exit $EXIT_CODE | |
fi | |
for FILE in `git diff-index --name-only --cached HEAD -- | egrep .py$`; do | |
flake8 ${REPO}/${FILE} --max-complexity=10 | |
EXIT_CODE=$((${EXIT_CODE} + $?)) | |
done | |
if [[ ${EXIT_CODE} -ne 0 ]]; then | |
echo "Aborted due to flake8 errors." | |
exit $EXIT_CODE | |
fi | |
exit $EXIT_CODE |
Fixed this in a fork: https://gist.github.com/aehlke/ea47c67a2cf1d01f711d so that this does not run flake8 on unstaged files, only on files that have been staged for the commit.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To install this, copy it to a file called
pre-commit
underTHM/.git/hooks/
. Thenchmod +x pre-commit
.