Convert stable to update.
[git-central.git] / tests / t2100-server-update-stable.sh
1 #!/bin/sh
2
3 test_description='server update stable enforcer'
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 "a" &&
11         git clone ./. server &&
12         rm -fr server/.git/hooks &&
13         git checkout -b stable &&
14         git remote add origin ./server &&
15         git push origin stable &&
16         git config --add branch.stable.remote origin &&
17         git config --add branch.stable.merge refs/heads/stable
18 '
19
20 # setup the update hook
21 install_server_hook 'update-stable' 'update'
22
23 test_expect_success 'reject commit directly to stable' '
24         echo $test_name >a &&
25         git commit -a -m "$test_name going onto stable" &&
26         head=$(git rev-parse HEAD) &&
27         ! git push 2>push.err &&
28         cat push.err | grep "Moving stable to $head includes a new commit" &&
29         git reset --hard HEAD^
30 '
31
32 test_expect_success 'reject aged topic branch' '
33         # make one topic branch
34         git checkout -b topic1 stable &&
35         echo $test_name >topic1 &&
36         git add topic1 &&
37         git commit -m "$test_name topic1" &&
38         git push origin topic1 &&
39
40         # now make another topic
41         git checkout -b topic2 stable
42         echo $test_name >topic2 &&
43         git add topic2 &&
44         git commit -m "$test_name topic2" &&
45         git push origin topic2 &&
46
47         # merge in topic2
48         git checkout stable &&
49         git merge topic2 &&
50         git push &&
51
52         # merge in topic1 fails
53         git merge topic1 &&
54         head=$(git rev-parse HEAD) &&
55         ! git push 2>push.err &&
56         cat push.err | grep "Moving stable to $head includes a new commit" &&
57         git reset --hard ORIG_HEAD
58 '
59
60 test_expect_success 'accept updated aged topic branch' '
61         # make one topic branch
62         git checkout -b topic3 stable &&
63         echo $test_name >topic3 &&
64         git add topic3 &&
65         git commit -m "$test_name topic3" &&
66         git push origin topic3 &&
67
68         # now make another topic
69         git checkout -b topic4 stable
70         echo $test_name >topic4 &&
71         git add topic4 &&
72         git commit -m "$test_name topic4" &&
73         git push origin topic4 &&
74
75         # merge in topic4
76         git checkout stable &&
77         git merge topic4 &&
78         git push &&
79
80         # update topic3 first
81         git checkout topic3 &&
82         git merge stable &&
83         git push &&
84
85         # Now we can update stable
86         git checkout stable &&
87         git merge topic3 &&
88         git push
89 '
90
91 test_done
92