Skip to content

Instantly share code, notes, and snippets.

@aehlke
Forked from hughes/pre-commit
Last active August 29, 2015 13:59
Show Gist options
  • Save aehlke/ea47c67a2cf1d01f711d to your computer and use it in GitHub Desktop.
Save aehlke/ea47c67a2cf1d01f711d to your computer and use it in GitHub Desktop.
#!/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
@hughes
Copy link

hughes commented May 2, 2014

sudo npm install -g jshint; sudo pip install flake8

From @brianpeiris:

To install this, copy it to a file called pre-commit under THM/.git/hooks/. Then chmod +x pre-commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment