Rename update-trac -> update-ensure-ticket-reference.
[git-central.git] / server / update-ensure-ticket-reference
1 #!/bin/sh
2
3 # Command line
4 refname="$1"
5 oldrev="$2"
6 newrev="$3"
7
8 if expr "$oldrev" : '0*$' >/dev/null ; then
9         git rev-parse --not --branches | git rev-list --stdin --no-merges $newrev
10 else
11         git rev-parse --not --branches | git rev-list --stdin --no-merges $oldrev..$newrev
12 fi | while read commit ; do
13         # Have log dump the "subject line, new line, body" of each commit message for grepping
14         git log -n 1 '--pretty=format:%s%n%b' "$commit" | grep -i '\(\(re\|refs\|qa\) #[0-9]\+\)\|\(no ticket\)' > /dev/null
15         if [ $? -ne 0 ] ; then
16                 echo "----------------------------------------------------" >&2
17                 echo "" >&2
18                 echo "Commit $commit does not reference a ticket" >&2
19                 echo "" >&2
20                 echo "----------------------------------------------------" >&2
21                 exit 1
22         fi
23 done
24