From c4faccbf0bee0127f0fd80a5934eba0a904c67ff Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 3 Nov 2006 20:19:55 +0100 Subject: [PATCH] Added a generic update hook script. --- update | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 update diff --git a/update b/update new file mode 100755 index 0000000..23fc8ec --- /dev/null +++ b/update @@ -0,0 +1,62 @@ +#!/bin/sh +# +# This is a generic update hook script for GIT repositories. +# +# Called by git-receive-pack with arguments: refname sha1-old sha1-new +# +# Expects the following environment variables: +# +# recipient where to send the mail reports to +# sub_prefix prefix which should be prepended to mail subject +# + +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="$sub_prefix" +else + subj="[$sub_prefix:$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 -C "$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 +mutt -F/dev/null -x -e 'set charset="utf-8"; set send_charset="us-ascii:iso-8859-2:utf-8"' -s "$subj" "$recipient" <$out +rm $out +exit 0 -- 2.39.2