-
-
Save NorthIsUp/2642490 to your computer and use it in GitHub Desktop.
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 | |
# | |
# 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