3 test_description='server update ensure merged'
7 test_expect_success 'setup' '
10 git commit -m "setup" &&
11 git clone ./. server &&
12 rm -fr server/.git/hooks &&
13 git remote add origin ./server &&
14 git config --add branch.master.remote origin &&
15 git config --add branch.master.merge refs/heads/master &&
17 git checkout -b stable &&
18 git push origin stable
21 install_server_hook 'update-ensure-merged' 'update'
23 test_expect_success 'pushing just topic is okay' '
24 git checkout -b topic &&
25 echo "$test_name" >a &&
26 git commit -a -m "$test_name on topic" &&
30 test_expect_success 'if topic moves on, tagging candidate requires a merge' '
31 git checkout -b candidate stable &&
32 git merge topic --no-ff &&
36 echo "$test_name on topic" >a &&
37 git commit -a -m "$test_name on topic" &&
40 git checkout candidate &&
41 git tag -a -m "Tagging candidate" deployment-1 &&
42 ! git push --tags 2>push.err &&
43 cat push.err | grep "Rejecting refs/tags/deployment-1 because you need to merge" &&
44 cat push.err | grep "topic" &&
47 git tag -d deployment-1 &&
48 git tag -a -m "Tagging candidate" deployment-1 &&
52 test_expect_success 'if stable moves on, tagging candidate requires a merge' '
53 git checkout stable &&
54 echo "$test_name on stable" >a.stable &&
56 git commit -a -m "$test_name on stable" &&
59 git checkout candidate &&
60 git tag -a -m "Tagging candidate" deployment-2 &&
61 ! git push --tags 2>push.err &&
62 cat push.err | grep "Rejecting refs/tags/deployment-2 because you need to merge" &&
63 cat push.err | grep "stable" &&
66 git tag -d deployment-2 &&
67 git tag -a -m "Tagging candidate" deployment-2 &&
71 test_expect_success 'when creating a candidate, it must be a merge' '
72 git checkout -b topic2 stable &&
73 echo "$test_name on topic2" >a &&
74 git commit -a -m "$test_name on topic2" &&
75 git push origin topic2 &&
77 git checkout -b candidate2 stable &&
79 ! git push origin candidate2 2>push.err &&
80 cat push.err | grep "Candidate branches must be only merges" &&
82 git reset --hard HEAD^ &&
83 git merge --no-ff topic2 &&
84 git push origin candidate2