Created
March 7, 2011 08:29
-
-
Save jonasvp/858223 to your computer and use it in GitHub Desktop.
My .git/hooks/pre-commit - save yourself from embarassment using pyflakes
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 | |
TMPDIR=`mktemp -d` | |
TMPFILE=`mktemp` | |
git diff --cached --name-only --diff-filter=ACMR | xargs git checkout-index --prefix=$TMPDIR/ -- | |
pyflakes $TMPDIR >$TMPFILE 2>&1 | |
grep -v "unable to detect undefined names" $TMPFILE >$TMPFILE.2 | |
egrep -v "migrations.*'(datetime|models)' imported but unused" $TMPFILE.2 >$TMPFILE | |
grep -rn "pdb.set_trace" $TMPDIR >>$TMPFILE | |
sed "s/^${TMPDIR//\//.}.//" $TMPFILE >$TMPFILE.2 | |
mv $TMPFILE.2 $TMPFILE | |
CODE=0 | |
OUTPUT=`cat $TMPFILE` | |
if [ -n "$OUTPUT" ]; then | |
cat $TMPFILE; | |
CODE=1; | |
fi | |
rm -Rf $TMPDIR $TMPFILE | |
exit $CODE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment