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