]> mj.ucw.cz Git - git-tools.git/blob - update
Makefile: Fixed release machinery
[git-tools.git] / update
1 #!/bin/bash
2 #
3 # This is a generic update hook script for GIT repositories.
4 # Written by Martin Mares <mj@ucw.cz> based on the template from GIT distribution.
5 #
6 # Called by git-receive-pack with arguments: refname sha1-old sha1-new
7 #
8 # Expects the following environment variables to be set:
9 #
10 #       recipient       where to send the mail reports to
11 #       sub_prefix      prefix which should be prepended to mail subject
12 #
13
14 branch=${1#refs/heads/}
15 if [ "$branch" == "$1" ] ; then
16         # Not something we care about
17         exit 0
18 fi
19 if [ $branch == origin ] ; then
20         # We are not following the origin
21         exit 0
22 fi
23
24 out=`mktemp -t gitlog.XXXXXXX`
25 if [ $branch == master ] ; then
26         subj="[$sub_prefix]"
27 else
28         subj="[$sub_prefix:$branch]"
29 fi
30 exec >$out
31
32 if expr "$2" : '0*$' >/dev/null ; then
33         echo "Created a new branch $branch, with the following commits:"
34         echo
35         git-rev-list --pretty --max-count=20 "$3"
36         echo "(and possibly more)"
37 else
38         base=$(git-merge-base "$2" "$3")
39         case "$base" in
40         "$2")
41                 echo "New commits to branch $branch:"
42                 ;;
43         *)
44                 echo "Rebased branch $branch, commits from common ancestor:"
45                 ;;
46         esac
47         echo
48         git-rev-list --pretty "$3" "^$base"
49         git-diff -C "$base" "$3"
50         t=`mktemp -t gitlog.XXXXXXX`
51         git-diff --name-only -r "$base" "$3" >$t
52         while read X ; do
53                 if [ ${#subj} -lt 80 ] ; then
54                         subj="$subj $X"
55                 fi
56         done <$t
57         rm $t
58 fi
59
60 exec >&2
61 mutt -F/dev/null -x -e 'set charset="utf-8"; set send_charset="us-ascii:iso-8859-2:utf-8"' -s "$subj" "$recipient" <$out
62 rm $out
63 exit 0