Skip to content

Instantly share code, notes, and snippets.

@terrycojones
Created April 25, 2015 21:47
Show Gist options
  • Save terrycojones/1f37f95e1270ccd3bc7a to your computer and use it in GitHub Desktop.
Save terrycojones/1f37f95e1270ccd3bc7a to your computer and use it in GitHub Desktop.
#!/bin/bash
# A Git pre-commit hook.
#
# To install:
#
# $ cd .git/hooks
# $ ln -s ../../bin/pre-commit.sh pre-commit
# Add our virtualenv bin to PATH. Git commit seems to muck with PATH :-(
if [ -n "$VIRTUAL_ENV" ]
then
PATH="$VIRTUAL_ENV/bin:$PATH"
fi
tmp=/tmp/git-pre-commit-$$
trap "rm -f $tmp" 0 1 2 3 15
make lint > $tmp 2>&1
if [ $? -ne 0 ]
then
echo 'COMMIT FAILED: make lint did not run cleanly:' >&2
cat $tmp >&2
exit 1
fi
make check > $tmp 2>&1
if [ $? -ne 0 ]
then
echo 'COMMIT FAILED: make check did not run cleanly:' >&2
cat $tmp >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment