]> mj.ucw.cz Git - libucw.git/blob - build/git/hooks/update
Merge with git+ssh://cvs.ucw.cz/projects/sherlock/GIT/sherlock.git#v3.8
[libucw.git] / build / git / hooks / update
1 #!/bin/sh
2 #
3 # Called by git-receive-pack with arguments: refname sha1-old sha1-new
4 #
5
6 #recipient="mj@ucw.cz"
7 recipient="sherlock-commits@host2.netcentrum.cz"
8
9 branch=${1#refs/heads/}
10 if [ "$branch" == "$1" ] ; then
11         # Not something we care about
12         exit 0
13 fi
14 if [ $branch == origin ] ; then
15         # We are not following the origin
16         exit 0
17 fi
18
19 out=`mktemp -t gitlog.XXXXXXX`
20 if [ $branch == master ] ; then
21         subj="[GIT]"
22 else
23         subj="[GIT:$branch]"
24 fi
25 exec >$out
26
27 if expr "$2" : '0*$' >/dev/null ; then
28         echo "Created a new branch $branch, with the following commits:"
29         echo
30         git-rev-list --pretty --max-count=20 "$3"
31         echo "(and possibly more)"
32 else
33         base=$(git-merge-base "$2" "$3")
34         case "$base" in
35         "$2")
36                 echo "New commits to branch $branch:"
37                 ;;
38         *)
39                 echo "Rebased branch $branch, commits from common ancestor:"
40                 ;;
41         esac
42         echo
43         git-rev-list --pretty "$3" "^$base"
44         git-diff "$base" "$3"
45         t=`mktemp -t gitlog.XXXXXXX`
46         git-diff --name-only -r "$base" "$3" >$t
47         while read X ; do
48                 if [ ${#subj} -lt 80 ] ; then
49                         subj="$subj $X"
50                 fi
51         done <$t
52         rm $t
53 fi 
54
55 exec >&2
56 mail -s "$subj" "$recipient" <$out
57 rm $out
58 exit 0