#!/bin/bash

# Note that you can (and it might be actually more desirable) also use this
# script as the GIT update hook:
#

GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
if [ -z "$GIT_DIR" ]; then
	echo >&2 "fatal: post-receive: GIT_DIR not set"
	exit 1
fi

branchname=${1#refs/heads/}
[ "$branchname" = "master" ] && branchname=
oldhead=$2
newhead=$3
for merged in $(git-rev-parse --symbolic-full-name --not --branches | egrep -v "^\^$1$" | git-rev-list --stdin $oldhead..$newhead | tac); do
  # Call your favorite announcement bot here
  # $GIT_DIR/hooks/announce $merged $branchname
  :
done
