Todo.
[git-central.git] / tests / t2102-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 '0-commit branches are not caught by future stable' '
52         git checkout -b topic4 stable &&
53         git push origin topic4 &&
54
55         echo "$test_name" > a &&
56         git commit -a -m "$test_name" &&
57         git push origin topic4
58 '
59
60 test_expect_success 'topic1 cannot be changed' '
61         git checkout topic1 &&
62         echo "$test_name" >a.topic1 &&
63         git commit -a -m "$test_name" &&
64         ! git push origin topic1 2>push.err &&
65         cat push.err | grep "topic1 has been merged into candidate1"
66 '
67
68 test_expect_success 'candidate1 can be changed' '
69         git checkout candidate1 &&
70         echo "$test_name" >a.topic1 &&
71         git commit -a -m "$test_name" &&
72         git push origin candidate1
73 '
74
75 test_expect_success 'merge candidate into stable' '
76         git checkout stable &&
77         git merge candidate1 --no-ff &&
78         git push origin stable
79 '
80
81 test_expect_success 'candidate cannot be changed' '
82         git checkout candidate1 &&
83         echo "$test_name" >a.topic1 &&
84         git commit -a -m "$test_name" &&
85         ! git push origin candidate1 2>push.err &&
86         cat push.err | grep "candidate1 has been merged into stable"
87         ! cat push.err | grep "candidate1 has been merged into candidate1"
88 '
89
90 test_expect_success 'topic1 cannot be changed' '
91         # It is already changed but error message should chagne
92         git checkout topic1 &&
93         ! git push origin topic1 2>push.err &&
94         cat push.err | grep "topic1 has been merged into stable" &&
95         git reset --hard HEAD^
96 '
97
98 test_expect_success 'topic3 can initially be created on stable and then moved' '
99         git checkout -b topic3 stable &&
100         git push origin topic3 &&
101
102         echo "$test_name" >a.topic3 &&
103         git add a.topic3 &&
104         git commit -m "$test_name" &&
105         git push origin topic3
106 '
107
108 test_done
109