Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/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