Skip to content

Instantly share code, notes, and snippets.

@drewinglis
Last active December 17, 2015 16:49
Show Gist options
  • Save drewinglis/5641323 to your computer and use it in GitHub Desktop.
Save drewinglis/5641323 to your computer and use it in GitHub Desktop.
#!/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