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 '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"
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
66 test_expect_success 'merge candidate into stable' '
67 git checkout stable &&
68 git merge candidate1 --no-ff &&
69 git push origin stable
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"
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^
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" &&
94 echo "$test_name" >a.topic3 &&
96 git commit -m "$test_name" &&
97 git push origin topic3
100 test_expect_failure 'topic4 cannot point to the same place as topic4' '
101 git checkout -b topic4 topic3 &&
102 echo "$test_name" >a.topic4 &&
104 git commit -m "making topic4" &&
105 git push origin topic4 &&
107 ! git push origin topic4:topic3 2>push.err &&
108 cat push.err | grep "topic3 is already referred to by topic4"