Get tests passing again.
[git-central.git] / server / update-ensure-ticket-reference
1 #!/bin/bash
2
3 . $(dirname $0)/functions
4
5 # Command line
6 refname="$1"
7 oldrev="$2"
8 newrev="$3"
9
10 # We only care about branches moving--ignore tags/etc.
11 case "$refname" in
12         refs/heads/*)
13                 short_refname=${refname##refs/heads/}
14                 ;;
15         *)
16                 exit 0
17                 ;;
18 esac
19
20 excused=" $(git config hooks.update-ensure-ticket-reference.excused) "
21 if [[ $excused =~ " $short_refname " ]] ; then
22         exit 0
23 fi
24
25 if expr "$oldrev" : '0*$' >/dev/null ; then
26         git rev-parse --not --branches | git rev-list --stdin --no-merges $newrev
27 else
28         git rev-parse --not --branches | git rev-list --stdin --no-merges $oldrev..$newrev
29 fi | while read commit ; do
30         # Have log dump the "subject line, new line, body" of each commit message for grepping
31         git log -n 1 '--pretty=format:%s%n%b' "$commit" | grep -i '\(\(re\|refs\|qa\) #[0-9]\+\)\|\(no ticket\)' > /dev/null
32         if [ $? -ne 0 ] ; then
33                 display_error_message "Commit $commit does not reference a ticket"
34                 exit 1
35         fi
36 done
37