update-no-rewind -> update-allow-tags-branches.
[git-central.git] / tests / t2001-server-pre-receive-trac-via-shim.sh
1 #!/bin/sh
2
3 test_description='server pre-receive trac ticket enforcer via shim'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         echo This is a test. >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 shim
19 install_server_hook 'noop' 'noop'
20 install_server_hook 'pre-receive-trac' 'pre-receive-trac'
21 install_server_hook 'pre-receive-trac-then-noop' 'pre-receive'
22
23 test_expect_success 'reject with bad message via shim' '
24         echo $test_name >a &&
25         git commit -a -m "$test_name" &&
26         head=$(git rev-parse HEAD) &&
27         ! git push >push.out 2>push.err &&
28         cat push.err | grep "Commit $head does not reference a ticket"
29 '
30
31 # the last test has a dirty commit message, so ammend it with a good message
32 test_expect_success 'accept with re via shim' '
33         echo $test_name >a &&
34         git commit --amend -m "$test_name re #3222" &&
35         git push
36 '
37
38 test_expect_success 'reject second push line has bad message via shim' '
39         # make a new remote branch
40         git branch topic1 master &&
41         git push origin topic1 &&
42
43         # change master
44         echo $test_name >a &&
45         git commit -a -m "$test_name re #3222"  &&
46
47         # change topic1 with no re
48         git checkout topic1 &&
49         echo "$test_name topic1" >a &&
50         git commit -a -m "$test_name" &&
51         head=$(git rev-parse HEAD) &&
52
53         ! git push >push.out 2>push.err &&
54         cat push.err | grep "Commit $head does not reference a ticket"
55 '
56
57 test_expect_success 'reject first push line has bad message via shim' '
58         # make a new remote branch
59         git branch topic2 master &&
60         git push origin topic2 &&
61
62         # change master first with no re
63         echo $test_name >a &&
64         git commit -a -m "$test_name"  &&
65         head=$(git rev-parse HEAD) &&
66
67         # change topic2 with re
68         git checkout topic2 &&
69         echo "$test_name topic2" >a &&
70         git commit -a -m "$test_name re #3222" &&
71
72         ! git push >push.out 2>push.err &&
73         cat push.err | grep "Commit $head does not reference a ticket"
74 '
75
76 test_done
77