Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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
# Global hooks for this repo (ie. set in Gitolite config).
hooks=$(git config --get
[ -z "$hooks" ] && continue
for hook in $hooks; do
run_hook $oldrev $newrev $refname $hook
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