3 test_description='server pre-receive stable enforcer'
7 test_expect_success 'setup' '
8 echo This is a test. >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
20 # setup the pre-receive hook
21 install_server_hook 'pre-receive-stable' 'pre-receive'
23 test_expect_success 'reject commit directly to stable' '
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^
32 test_expect_success 'reject aged topic branch' '
33 # make one topic branch
34 git checkout -b topic1 stable &&
35 echo $test_name >topic1 &&
37 git commit -m "$test_name topic1" &&
38 git push origin topic1 &&
40 # now make another topic
41 git checkout -b topic2 stable
42 echo $test_name >topic2 &&
44 git commit -m "$test_name topic2" &&
45 git push origin topic2 &&
48 git checkout stable &&
52 # merge in topic1 fails
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
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 &&
65 git commit -m "$test_name topic3" &&
66 git push origin topic3 &&
68 # now make another topic
69 git checkout -b topic4 stable
70 echo $test_name >topic4 &&
72 git commit -m "$test_name topic4" &&
73 git push origin topic4 &&
76 git checkout stable &&
81 git checkout topic3 &&
85 # Now we can update stable
86 git checkout stable &&