Last active
December 17, 2015 16:49
-
-
Save drewinglis/5641323 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 | |
run_hook () { | |
echo -en "\e[1;33m$4..\e[00m " | |
echo $1 $2 $3 | $GIT_DIR/hooks/hooks.d/$4 | |
} | |
echo -en "\e[1;33mRunning hooks..\e[00m " | |
while read oldrev newrev refname; do | |
hooks=$(git cat-file blob $newrev:.hooks 2>/dev/null) | |
if [ -n "$hooks" ]; then | |
# Repo-local hooks defined in .hooks. | |
for hook in $hooks; do | |
run_hook $oldrev $newrev $refname $hook | |
done | |
fi | |
# Global hooks for this repo (ie. set in Gitolite config). | |
hooks=$(git config --get hooks.run) | |
[ -z "$hooks" ] && continue | |
for hook in $hooks; do | |
run_hook $oldrev $newrev $refname $hook | |
done | |
done | |
echo -e "\e[1;32mDone.\e[00m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment