Skip to content

Instantly share code, notes, and snippets.

@NorthIsUp
Forked from mikeclarke/gist:2642393
Created May 9, 2012 06:41
Show Gist options
  • Save NorthIsUp/2642490 to your computer and use it in GitHub Desktop.
Save NorthIsUp/2642490 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# A git hook for automatically running commands
# based on the name of files modified in the
# previous changeset
#
# To install as a post-merge hook (on `git pull`):
# $ cp hook.sh .git/hooks/post-merge && chmod 755 $_
#
# To install as a post-checkout hook (changing branches):
# $ cp hook.sh .git/hooks/post-checkout && chmod 755 $_
#
KEYWORDS=( 'requirements' 'paver' )
# Check if we're in a virtualenv
python -c "import sys; sys.real_prefix" &> /dev/null
# Check if keywords in changed files list
if [ $? -eq 0 ]; then
for MATCH in "$KEYWORDS"
do
git diff --name-only HEAD@{1} HEAD | grep -q $MATCH
if [ $? -eq 0 ]; then
paver update
exit
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment