Rename update-trac -> update-ensure-ticket-reference.
[git-central.git] / tests / t2002-server-update-ensure-ticket-reference-branches.sh
1 #!/bin/sh
2
3 test_description='server update trac ticket enforcer via shim'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         echo "setup" >a &&
9         git add a &&
10         git commit -m "setup" &&
11         git clone ./. server &&
12         rm -fr server/.git/hooks &&
13         git remote add origin ./server &&
14         git config --add branch.master.remote origin &&
15         git config --add branch.master.merge refs/heads/master
16 '
17
18 # setup the hook
19 install_server_hook 'update-ensure-ticket-reference' 'update'
20
21 test_expect_success 'reject new branch with bad message' '
22         git checkout -b topic1 master &&
23         echo $test_name >a &&
24         git commit -a -m "$test_name" &&
25         head=$(git rev-parse HEAD)
26         ! git push origin topic1 >push.out 2>push.err &&
27         cat push.err | grep "Commit $head does not reference a ticket"
28 '
29
30 # the last test has a dirty commit message, so ammend it with a good message
31 test_expect_success 'accept new branch with re' '
32         git checkout -b topic2 master &&
33         echo $test_name >a &&
34         git commit --amend -m "$test_name re #3222" &&
35         git push origin topic2
36 '
37
38 test_expect_success 'reject new branch with bad message in second of three' '
39         git checkout -b topic3 master &&
40         echo "$test_name first" >a &&
41         git commit -a -m "$test_name first re #3222" &&
42
43         # the bad one
44         echo "$test_name second" >a &&
45         git commit -a -m "$test_name second" &&
46         head=$(git rev-parse HEAD) &&
47
48         echo "$test_name third" >a &&
49         git commit -a -m "$test_name third re #3222" &&
50
51         ! git push origin topic3 >push.out 2>push.err &&
52         cat push.err | grep "Commit $head does not reference a ticket"
53 '
54
55 test_expect_success 'accept new branch with re in all of three' '
56         git checkout -b topic4 master &&
57         echo "$test_name first" >a &&
58         git commit -a -m "$test_name first re #3222" &&
59
60         # the bad one
61         echo "$test_name second" >a &&
62         git commit -a -m "$test_name second re #3222" &&
63         head=$(git rev-parse HEAD) &&
64
65         echo "$test_name third" >a &&
66         git commit -a -m "$test_name third re #3222" &&
67
68         git push origin topic4
69 '
70
71 test_done
72