3 test_description='server update ensure follows'
7 test_expect_success 'setup' '
10 git commit -m "setup" &&
11 git clone -l . --bare server.git &&
12 rm -fr server.git/hooks &&
13 git remote add origin ./server.git &&
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' '
25 GIT_DIR=server.git git config hooks.update-ensure-follows.branches stable &&
27 git checkout -b topic1 &&
28 echo "$test_name" >a.topic1 &&
30 git commit -m "Add on topic1." &&
31 git push origin topic1
34 test_expect_success 'branch with moved stable requires merge' '
35 git checkout stable &&
36 echo "$test_name" >a &&
37 git commit -a -m "Change on stable" &&
38 git push origin stable &&
40 git checkout topic1 &&
41 echo "$test_name" >a.topic1 &&
42 git commit -a -m "Change on topic1." &&
43 ! git push origin topic1 2>push.err &&
44 cat push.err | grep "You need to merge stable into topic1" &&
47 git push origin topic1
50 test_expect_success 'branch with moved stable is told to update first' '
51 git checkout stable &&
52 echo "$test_name" >a &&
53 git commit -a -m "Change on stable" &&
54 git push origin stable &&
56 # Someone fixes stable first
57 git clone server.git person2 &&
59 git checkout -f topic1 &&
60 git remote add server ../server.git &&
61 git merge origin/stable &&
62 git push server topic1 &&
65 git checkout topic1 &&
66 echo "$test_name" >a.topic1 &&
67 git commit -a -m "Change on topic1." &&
68 ! git push --force origin topic1 2>push.err &&
69 cat push.err | grep "You need to update your local branch topic1" &&
71 # Now it will work as the teammate merged for us
72 git pull origin topic1 &&
73 git push origin topic1
76 test_expect_success 'branch with moved stable as second branch requires merge' '
77 GIT_DIR=server.git git config hooks.update-ensure-follows.branches "foo stable" &&
79 git checkout stable &&
80 echo "$test_name" >a &&
81 git commit -a -m "Change on stable" &&
82 git push origin stable &&
84 git checkout topic1 &&
85 echo "$test_name" >a.topic1 &&
86 git commit -a -m "Change on topic1." &&
87 ! git push origin topic1 2>push.err &&
88 cat push.err | grep "You need to merge stable into topic1" &&
91 git push origin topic1
94 test_expect_success 'tag with moved stable is okay' '
95 git checkout stable &&
96 echo "$test_name" >a &&
97 git commit -a -m "Change on stable" &&
98 git push origin stable &&
100 git checkout topic1 &&
105 test_expect_success 'branch deletion with moved stable is okay' '
106 git checkout stable &&
107 echo "$test_name" >a &&
108 git commit -a -m "Change on stable" &&
110 git push origin :topic1
113 test_expect_success 'excused branch with moved stable is okay' '
114 git checkout -b topic2 stable &&
115 echo "$test_name" >a.topic2 &&
117 git commit -m "Change on topic2" &&
118 git push origin topic2 &&
120 git checkout stable &&
121 echo "$test_name" >a &&
122 git commit -a -m "Change on stable" &&
123 git push origin stable &&
125 git checkout topic2 &&
126 echo "$test_name foo" >a.topic2 &&
127 git commit -a -m "Change on topic2 again" &&
128 ! git push origin topic2 &&
130 GIT_DIR=server.git git config hooks.update-ensure-follows.excused topic2 &&
132 git push origin topic2
135 test_expect_success 'new branch without stable gets nicer error' '
136 git checkout -b topic3 stable &&
137 echo "$test_name" >a.topic3 &&
139 git commit -m "Change on topic3" &&
141 git checkout stable &&
142 echo "$test_name" >a &&
143 git commit -a -m "Change on stable" &&
144 git push origin stable &&
146 git checkout topic3 &&
147 ! git push origin topic3 2>push.err &&
148 grep "You need to merge stable into topic3" push.err &&
151 git push origin topic3