-
-
Save bartek/44525cbbc8394f65478eb3094521961f to your computer and use it in GitHub Desktop.
pre commit hook for running pylint
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 | |
DESIRED_VENV=compass | |
if [ -z $VIRTUAL_ENV ] || [ "`basename $VIRTUAL_ENV`" != "$DESIRED_VENV" ]; then | |
echo You\'re not in the $DESIRED_VENV virtualenv, \`workon $DESIRED_VENV\` to fix. | |
exit 1 | |
fi | |
RCFILE="`git rev-parse --show-toplevel`"/.pylintrc | |
[ -e "$RCFILE" ] || echo "Cannot find $RCFILE" | |
FILES=`git diff-index --cached HEAD | awk '{ printf $6" " }'` | |
if [ -z "$FILES" ]; then | |
echo "Nothing to commit" | |
exit 1 | |
fi | |
COMMAND="pylint --rcfile='$RCFILE' $FILES" | |
OUTPUT="`$COMMAND 2>&1`" | |
echo $COMMAND | |
echo "$OUTPUT" | |
echo "$OUTPUT" | awk '/^E:/ { exit 1 }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment