3 test_description='server update candidate enforcer'
7 test_expect_success 'setup' '
11 git clone ./. server &&
12 git remote add origin ./server &&
13 rm -fr server/.git/hooks
16 # setup the update hook
17 install_update_hook 'update-stable'
19 test_expect_success 'initial stable commit works' '
20 # do one stable-less commit
22 git commit -a -m "$test_name" &&
23 git push origin master &&
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
31 test_expect_success 'create topic1 and topic2' '
32 git checkout -b topic1 stable &&
33 echo "$test_name topic1" >a.topic1 &&
35 git commit -m "start topic1" &&
37 git checkout -b topic2 stable &&
38 echo "$test_name topic2" >a.topic2 &&
40 git commit -m "start topic2" &&
42 git push origin topic2 topic1
45 test_expect_success 'create candidate1' '
46 git checkout -b candidate1 stable &&
47 git merge topic1 topic2 &&
48 git push origin candidate1
51 test_expect_success '0-commit branches are not caught by future stable' '
52 git checkout -b topic4 stable &&
53 git push origin topic4 &&
55 echo "$test_name" > a &&
56 git commit -a -m "$test_name" &&
57 git push origin topic4
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"
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
75 test_expect_success 'merge candidate into stable' '
76 git checkout stable &&
77 git merge candidate1 --no-ff &&
78 git push origin stable
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"
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^
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 &&
102 echo "$test_name" >a.topic3 &&
104 git commit -m "$test_name" &&
105 git push origin topic3