]> mj.ucw.cz Git - libucw.git/commitdiff
Added the update hook script to the repository.
authorMartin Mares <mj@ucw.cz>
Fri, 24 Feb 2006 13:26:31 +0000 (14:26 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 24 Feb 2006 13:26:31 +0000 (14:26 +0100)
build/git/hooks/update [new file with mode: 0755]

diff --git a/build/git/hooks/update b/build/git/hooks/update
new file mode 100755 (executable)
index 0000000..a701153
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+# Called by git-receive-pack with arguments: refname sha1-old sha1-new
+#
+
+#recipient="mj@ucw.cz"
+recipient="sherlock-commits@host2.netcentrum.cz"
+
+branch=${1#refs/heads/}
+if [ "$branch" == "$1" ] ; then
+       # Not something we care about
+       exit 0
+fi
+if [ $branch == origin ] ; then
+       # We are not following the origin
+       exit 0
+fi
+
+out=`mktemp -t gitlog.XXXXXXX`
+if [ $branch == master ] ; then
+       subj="[GIT]"
+else
+       subj="[GIT:$branch]"
+fi
+exec >$out
+
+if expr "$2" : '0*$' >/dev/null ; then
+       echo "Created a new branch $branch, with the following commits:"
+       echo
+       git-rev-list --pretty --max-count=20 "$3"
+       echo "(and possibly more)"
+else
+       base=$(git-merge-base "$2" "$3")
+       case "$base" in
+       "$2")
+               echo "New commits to branch $branch:"
+               ;;
+       *)
+               echo "Rebased branch $branch, commits from common ancestor:"
+               ;;
+       esac
+       echo
+       git-rev-list --pretty "$3" "^$base"
+       git-diff "$base" "$3"
+       t=`mktemp -t gitlog.XXXXXXX`
+       git-diff --name-only -r "$base" "$3" >$t
+       while read X ; do
+               if [ ${#subj} -lt 80 ] ; then
+                       subj="$subj $X"
+               fi
+       done <$t
+       rm $t
+fi 
+
+exec >&2
+mail -s "$subj" "$recipient" <$out
+rm $out
+exit 0