3 test_description='server update ensure follows'
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 &&
17 install_update_hook 'update-ensure-follows'
19 test_expect_success 'pushing stable works' '
20 git checkout -b stable &&
21 git push origin stable
24 test_expect_success 'branch with unmoved stable is okay' '
26 git config hooks.update-ensure-follows.branches stable &&
29 git checkout -b topic1 &&
30 echo "$test_name" >a.topic1 &&
32 git commit -m "Add on topic1." &&
33 git push origin topic1
36 test_expect_success 'branch with moved stable requires merge' '
37 git checkout stable &&
38 echo "$test_name" >a &&
39 git commit -a -m "Change on stable" &&
40 git push origin stable &&
42 git checkout topic1 &&
43 echo "$test_name" >a.topic1 &&
44 git commit -a -m "Change on topic1." &&
45 ! git push origin topic1 2>push.err &&
46 cat push.err | grep "You need to merge stable into topic1" &&
49 git push origin topic1
52 test_expect_success 'branch with moved stable is told to update first' '
53 git checkout stable &&
54 echo "$test_name" >a &&
55 git commit -a -m "Change on stable" &&
56 git push origin stable &&
58 # Someone fixes stable first
60 git checkout -f topic1 &&
64 git checkout topic1 &&
65 echo "$test_name" >a.topic1 &&
66 git commit -a -m "Change on topic1." &&
67 ! git push --force origin topic1 2>push.err &&
68 cat push.err | grep "You need to update your local branch topic1" &&
70 # Now it will work as the teammate merged for us
71 git pull origin topic1 &&
72 git push origin topic1
75 test_expect_success 'branch with moved stable as second branch requires merge' '
77 git config hooks.update-ensure-follows.branches "foo stable" &&
80 git checkout stable &&
81 echo "$test_name" >a &&
82 git commit -a -m "Change on stable" &&
83 git push origin stable &&
85 git checkout topic1 &&
86 echo "$test_name" >a.topic1 &&
87 git commit -a -m "Change on topic1." &&
88 ! git push origin topic1 2>push.err &&
89 cat push.err | grep "You need to merge stable into topic1" &&
92 git push origin topic1
95 test_expect_success 'tag with moved stable is okay' '
96 git checkout stable &&
97 echo "$test_name" >a &&
98 git commit -a -m "Change on stable" &&
99 git push origin stable &&
101 git checkout topic1 &&
106 test_expect_success 'branch deletion with moved stable is okay' '
107 git checkout stable &&
108 echo "$test_name" >a &&
109 git commit -a -m "Change on stable" &&
111 git push origin :topic1
114 test_expect_success 'excused branch with moved stable is okay' '
115 git checkout -b topic2 stable &&
116 echo "$test_name" >a.topic2 &&
118 git commit -m "Change on topic2" &&
119 git push origin topic2 &&
121 git checkout stable &&
122 echo "$test_name" >a &&
123 git commit -a -m "Change on stable" &&
124 git push origin stable &&
126 git checkout topic2 &&
127 echo "$test_name foo" >a.topic2 &&
128 git commit -a -m "Change on topic2 again" &&
129 ! git push origin topic2 &&
132 git config hooks.update-ensure-follows.excused topic2 &&
135 git push origin topic2