Skip to content

Instantly share code, notes, and snippets.

@frimik
Created April 26, 2012 21:02
Show Gist options
  • Select an option

  • Save frimik/2503225 to your computer and use it in GitHub Desktop.

Select an option

Save frimik/2503225 to your computer and use it in GitHub Desktop.
post-receive
#! /bin/sh
# This hook copies stdin to a temporary file, then executes
# hook scripts based on git config data.
#
# If you set the git config hooks.post-receive value to "hook1", this script
# will execute "hook1" if post-receive.hook1 exists, and is executable.
#
# Gitolite configuration example:
#
# repo bid-oopsie
# config hooks.post-receive = "irc email"
# config hooks.mailinglist = "oopsie@example.com"
# config hooks.emailprefix = "[bid-oopsie]"
# config hooks.irc.channel = "#ops"
# RW+ = @bid-oopsie
# R = @all
#
#
# Author: Mikael Fridh
# Based on: https://wiki.icinga.org/display/community/GIT+Commit+Bot
#
FILE=$(mktemp)
cat - > $FILE
HOOKPATH=$(dirname $0)
POSTRECEIVE_HOOKS=$(git config hooks.post-receive)
for hook in $POSTRECEIVE_HOOKS; do
if [ -x ${HOOKPATH}/post-receive.${hook} ];
then
cat $FILE | ${HOOKPATH}/post-receive.${hook}
fi
done
rm $FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment