Remove the server-/client- prefixes in the tests.
[git-central.git] / tests / t2500-update-ensure-merged.sh
1 #!/bin/sh
2
3 test_description='server update ensure merged'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         echo "setup" >a &&
9         git add a &&
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 &&
16         git fetch &&
17         git checkout -b stable &&
18         git push origin stable
19 '
20
21 install_server_hook 'update-ensure-merged' 'update'
22
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" &&
27         git push origin topic
28 '
29
30 test_expect_failure 'if topic moves on, tagging candidate requires a merge' '
31         git checkout -b candidate stable &&
32         git merge topic --no-ff &&
33         git push &&
34
35         git checkout topic &&
36         echo "$test_name on topic" >a &&
37         git commit -a -m "$test_name on topic" &&
38         git push &&
39
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" &&
45
46         git merge topic &&
47         git tag -d deployment-1 &&
48         git tag -a -m "Tagging candidate" deployment-1 &&
49         git push --tags
50 '
51
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 &&
55         git add a.stable &&
56         git commit -a -m "$test_name on stable" &&
57         git push &&
58
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" &&
64
65         git merge stable &&
66         git tag -d deployment-2 &&
67         git tag -a -m "Tagging candidate" deployment-2 &&
68         git push --tags
69 '
70
71 test_expect_failure '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 &&
76
77         git checkout -b candidate2 stable &&
78         git merge topic2 &&
79         ! git push origin candidate2 2>push.err &&
80         cat push.err | grep "Candidate branches must be only merges" &&
81
82         git reset --hard HEAD^ &&
83         git merge --no-ff topic2 &&
84         git push origin candidate2
85 '
86
87 test_done
88