Add excused to ensure follows.
[git-central.git] / tests / t2700-server-ensure-follows.sh
1 #!/bin/sh
2
3 test_description='server update ensure follows'
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 '
18
19 install_update_hook 'update-ensure-follows'
20
21 test_expect_success 'pushing stable works' '
22         git checkout -b stable &&
23         git push origin stable
24 '
25
26 test_expect_success 'branch with unmoved stable is okay' '
27         cd server &&
28         git config hooks.update-ensure-follows.branches stable &&
29         cd .. &&
30
31         git checkout -b topic1 &&
32         echo "$test_name" >a.topic1 &&
33         git add a.topic1 &&
34         git commit -m "Add on topic1." &&
35         git push origin topic1
36 '
37
38 test_expect_success 'branch with moved stable requires merge' '
39         git checkout stable &&
40         echo "$test_name" >a &&
41         git commit -a -m "Change on stable" &&
42         git push origin stable &&
43
44         git checkout topic1 &&
45         echo "$test_name" >a.topic1 &&
46         git commit -a -m "Change on topic1." &&
47         ! git push origin topic1 2>push.err &&
48         cat push.err | grep "You need to merge stable into topic1" &&
49
50         git merge stable &&
51         git push origin topic1
52 '
53
54 test_expect_success 'branch with moved stable as second branch requires merge' '
55         cd server &&
56         git config hooks.update-ensure-follows.branches "foo stable" &&
57         cd .. &&
58
59         git checkout stable &&
60         echo "$test_name" >a &&
61         git commit -a -m "Change on stable" &&
62         git push origin stable &&
63
64         git checkout topic1 &&
65         echo "$test_name" >a.topic1 &&
66         git commit -a -m "Change on topic1." &&
67         ! git push origin topic1 2>push.err &&
68         cat push.err | grep "You need to merge stable into topic1" &&
69
70         git merge stable &&
71         git push origin topic1
72 '
73
74 test_expect_success 'tag with moved stable is okay' '
75         git checkout stable &&
76         echo "$test_name" >a &&
77         git commit -a -m "Change on stable" &&
78         git push origin stable &&
79
80         git checkout topic1 &&
81         git tag topic1-tag1
82         git push --tags
83 '
84
85 test_expect_success 'branch deletion with moved stable is okay' '
86         git checkout stable &&
87         echo "$test_name" >a &&
88         git commit -a -m "Change on stable" &&
89
90         git push origin :topic1
91 '
92
93 test_expect_success 'excused branch with moved stable is okay' '
94         git checkout -b topic2 stable &&
95         echo "$test_name" >a.topic2 &&
96         git add a.topic2 &&
97         git commit -m "Change on topic2" &&
98         git push origin topic2 &&
99
100         git checkout stable &&
101         echo "$test_name" >a &&
102         git commit -a -m "Change on stable" &&
103         git push origin stable &&
104
105         git checkout topic2 &&
106         echo "$test_name foo" >a.topic2 &&
107         git commit -a -m "Change on topic2 again" &&
108         ! git push origin topic2 &&
109
110         cd server &&
111         git config hooks.update-ensure-follows.excused topic2 &&
112         cd .. &&
113
114         git push origin topic2
115 '
116
117 test_done
118