Better tattoo.
[git-central.git] / tests / t2102-server-update-stable-candidate.sh
1 #!/bin/sh
2
3 test_description='server update candidate enforcer'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         echo setup >a &&
9         git add a &&
10         git commit -m "a" &&
11         git clone ./. server &&
12         git remote add origin ./server &&
13         rm -fr server/.git/hooks
14 '
15
16 # setup the update hook
17 install_update_hook 'update-stable'
18
19 test_expect_success 'initial stable commit works' '
20         # do one stable-less commit
21         echo $test_name >a &&
22         git commit -a -m "$test_name" &&
23         git push origin master &&
24
25         git checkout -b stable &&
26         git push origin stable &&
27         git config --add branch.stable.remote origin &&
28         git config --add branch.stable.merge refs/heads/stable
29 '
30
31 test_expect_success 'create topic1 and topic2' '
32         git checkout -b topic1 stable &&
33         echo "$test_name topic1" >a.topic1 &&
34         git add a.topic1 &&
35         git commit -m "start topic1" &&
36
37         git checkout -b topic2 stable &&
38         echo "$test_name topic2" >a.topic2 &&
39         git add a.topic2 &&
40         git commit -m "start topic2" &&
41
42         git push origin topic2 topic1
43 '
44
45 test_expect_success 'create candidate1' '
46         git checkout -b candidate1 stable &&
47         git merge topic1 topic2 &&
48         git push origin candidate1
49 '
50
51 test_expect_success 'topic1 cannot be changed' '
52         git checkout topic1 &&
53         echo "$test_name" >a.topic1 &&
54         git commit -a -m "$test_name" &&
55         ! git push origin topic1 2>push.err &&
56         cat push.err | grep "topic1 has been merged into candidate1"
57 '
58
59 test_expect_success 'candidate1 can be changed' '
60         git checkout candidate1 &&
61         echo "$test_name" >a.topic1 &&
62         git commit -a -m "$test_name" &&
63         git push origin candidate1
64 '
65
66 test_expect_success 'merge candidate into stable' '
67         git checkout stable &&
68         git merge candidate1 --no-ff &&
69         git push origin stable
70 '
71
72 test_expect_success 'candidate cannot be changed' '
73         git checkout candidate1 &&
74         echo "$test_name" >a.topic1 &&
75         git commit -a -m "$test_name" &&
76         ! git push origin candidate1 2>push.err &&
77         cat push.err | grep "candidate1 has been merged into stable"
78         ! cat push.err | grep "candidate1 has been merged into candidate1"
79 '
80
81 test_expect_success 'topic1 cannot be changed' '
82         # It is already changed but error message should chagne
83         git checkout topic1 &&
84         ! git push origin topic1 2>push.err &&
85         cat push.err | grep "topic1 has been merged into stable" &&
86         git reset --hard HEAD^
87 '
88
89 test_expect_success 'topic3 cannot initially be created on stable' '
90         git checkout -b topic3 stable &&
91         ! git push origin topic3 2>push.err &&
92         cat push.err | grep "Creating a branch must include new commits" &&
93
94         echo "$test_name" >a.topic3 &&
95         git add a.topic3 &&
96         git commit -m "$test_name" &&
97         git push origin topic3
98 '
99
100 test_expect_success 'topic4 cannot point to the same place as topic4' '
101         git checkout -b topic4 topic3 &&
102         echo "$test_name" >a.topic4 &&
103         git add a.topic4 &&
104         git commit -m "making topic4" &&
105         git push origin topic4 &&
106
107         ! git push origin topic4:topic3 2>push.err &&
108         cat push.err | grep "topic3 is already referred to by topic4"
109 '
110
111 test_done
112