]>
Commit | Line | Data |
---|---|---|
15d3af5e | 1 | test_expect_success "setup proc-receive hook (option without matching ok, $PROTOCOL/porcelain)" ' |
c39176b1 | 2 | test_hook -C "$upstream" --clobber proc-receive <<-EOF |
15d3af5e JX |
3 | printf >&2 "# proc-receive hook\n" |
4 | test-tool proc-receive -v \ | |
5 | -r "option refname refs/pull/123/head" \ | |
6 | -r "option old-oid $B" | |
7 | EOF | |
8 | ' | |
9 | ||
8f0a2645 JS |
10 | # Refs of upstream : main(A) |
11 | # Refs of workbench: main(A) tags/v123 | |
12 | # git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) | |
15d3af5e JX |
13 | test_expect_success "proc-receive: report option without matching ok ($PROTOCOL/porcelain)" ' |
14 | test_must_fail git -C workbench push --porcelain origin \ | |
8f0a2645 | 15 | HEAD:refs/for/main/topic \ |
8388a64c JX |
16 | >out-$test_count 2>&1 && |
17 | make_user_friendly_and_stable_output <out-$test_count >actual && | |
2bafb3d7 JX |
18 | format_and_save_expect <<-EOF && |
19 | > remote: # pre-receive hook Z | |
20 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
21 | > remote: # proc-receive hook Z | |
22 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
23 | > remote: proc-receive> option refname refs/pull/123/head Z | |
24 | > remote: proc-receive> option old-oid <COMMIT-B> Z | |
25 | > remote: error: proc-receive reported "option" without a matching "ok/ng" directive Z | |
26 | > To <URL/of/upstream.git> | |
27 | > ! HEAD:refs/for/main/topic [remote rejected] (proc-receive failed to report status) | |
28 | > Done | |
15d3af5e JX |
29 | EOF |
30 | test_cmp expect actual | |
31 | ' | |
32 | ||
33 | test_expect_success "setup proc-receive hook (option refname, $PROTOCOL/porcelain)" ' | |
c39176b1 | 34 | test_hook -C "$upstream" --clobber proc-receive <<-\EOF |
15d3af5e JX |
35 | printf >&2 "# proc-receive hook\n" |
36 | test-tool proc-receive -v \ | |
8f0a2645 | 37 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
38 | -r "option refname refs/pull/123/head" |
39 | EOF | |
40 | ' | |
41 | ||
8f0a2645 JS |
42 | # Refs of upstream : main(A) |
43 | # Refs of workbench: main(A) tags/v123 | |
44 | # git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) | |
15d3af5e JX |
45 | test_expect_success "proc-receive: report option refname ($PROTOCOL/porcelain)" ' |
46 | git -C workbench push --porcelain origin \ | |
8f0a2645 | 47 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
48 | >out 2>&1 && |
49 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
50 | format_and_save_expect <<-EOF && |
51 | > remote: # pre-receive hook Z | |
52 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
53 | > remote: # proc-receive hook Z | |
54 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
55 | > remote: proc-receive> ok refs/for/main/topic Z | |
56 | > remote: proc-receive> option refname refs/pull/123/head Z | |
57 | > remote: # post-receive hook Z | |
58 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head Z | |
59 | > To <URL/of/upstream.git> | |
60 | > * HEAD:refs/pull/123/head [new reference] | |
61 | > Done | |
15d3af5e JX |
62 | EOF |
63 | test_cmp expect actual | |
64 | ' | |
65 | ||
66 | test_expect_success "setup proc-receive hook (option refname and forced-update, $PROTOCOL/porcelain)" ' | |
c39176b1 | 67 | test_hook -C "$upstream" --clobber proc-receive <<-\EOF |
15d3af5e JX |
68 | printf >&2 "# proc-receive hook\n" |
69 | test-tool proc-receive -v \ | |
8f0a2645 | 70 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
71 | -r "option refname refs/pull/123/head" \ |
72 | -r "option forced-update" | |
73 | EOF | |
74 | ' | |
75 | ||
8f0a2645 JS |
76 | # Refs of upstream : main(A) |
77 | # Refs of workbench: main(A) tags/v123 | |
78 | # git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) | |
15d3af5e JX |
79 | test_expect_success "proc-receive: report option refname and forced-update ($PROTOCOL/porcelain)" ' |
80 | git -C workbench push --porcelain origin \ | |
8f0a2645 | 81 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
82 | >out 2>&1 && |
83 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
84 | format_and_save_expect <<-EOF && |
85 | > remote: # pre-receive hook Z | |
86 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
87 | > remote: # proc-receive hook Z | |
88 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
89 | > remote: proc-receive> ok refs/for/main/topic Z | |
90 | > remote: proc-receive> option refname refs/pull/123/head Z | |
91 | > remote: proc-receive> option forced-update Z | |
92 | > remote: # post-receive hook Z | |
93 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head Z | |
94 | > To <URL/of/upstream.git> | |
95 | > * HEAD:refs/pull/123/head [new reference] | |
96 | > Done | |
15d3af5e JX |
97 | EOF |
98 | test_cmp expect actual | |
99 | ' | |
100 | ||
101 | test_expect_success "setup proc-receive hook (option refname and old-oid, $PROTOCOL/porcelain)" ' | |
c39176b1 | 102 | test_hook -C "$upstream" --clobber proc-receive <<-EOF |
15d3af5e JX |
103 | printf >&2 "# proc-receive hook\n" |
104 | test-tool proc-receive -v \ | |
8f0a2645 | 105 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
106 | -r "option refname refs/pull/123/head" \ |
107 | -r "option old-oid $B" | |
108 | EOF | |
109 | ' | |
110 | ||
8f0a2645 JS |
111 | # Refs of upstream : main(A) |
112 | # Refs of workbench: main(A) tags/v123 | |
113 | # git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) | |
15d3af5e JX |
114 | test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL/porcelain)" ' |
115 | git -C workbench push --porcelain origin \ | |
8f0a2645 | 116 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
117 | >out 2>&1 && |
118 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
119 | format_and_save_expect <<-EOF && |
120 | > remote: # pre-receive hook Z | |
121 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
122 | > remote: # proc-receive hook Z | |
123 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
124 | > remote: proc-receive> ok refs/for/main/topic Z | |
125 | > remote: proc-receive> option refname refs/pull/123/head Z | |
126 | > remote: proc-receive> option old-oid <COMMIT-B> Z | |
127 | > remote: # post-receive hook Z | |
128 | > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/123/head Z | |
129 | > To <URL/of/upstream.git> | |
12d6991c | 130 | > HEAD:refs/pull/123/head <COMMIT-B>..<COMMIT-A> |
2bafb3d7 | 131 | > Done |
15d3af5e JX |
132 | EOF |
133 | test_cmp expect actual | |
134 | ' | |
135 | ||
136 | test_expect_success "setup proc-receive hook (option old-oid, $PROTOCOL/porcelain)" ' | |
c39176b1 | 137 | test_hook -C "$upstream" --clobber proc-receive <<-EOF |
15d3af5e JX |
138 | printf >&2 "# proc-receive hook\n" |
139 | test-tool proc-receive -v \ | |
8f0a2645 | 140 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
141 | -r "option old-oid $B" |
142 | EOF | |
143 | ' | |
144 | ||
8f0a2645 JS |
145 | # Refs of upstream : main(A) |
146 | # Refs of workbench: main(A) tags/v123 | |
147 | # git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) | |
15d3af5e JX |
148 | test_expect_success "proc-receive: report option old-oid ($PROTOCOL/porcelain)" ' |
149 | git -C workbench push --porcelain origin \ | |
8f0a2645 | 150 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
151 | >out 2>&1 && |
152 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
153 | format_and_save_expect <<-EOF && |
154 | > remote: # pre-receive hook Z | |
155 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
156 | > remote: # proc-receive hook Z | |
157 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
158 | > remote: proc-receive> ok refs/for/main/topic Z | |
159 | > remote: proc-receive> option old-oid <COMMIT-B> Z | |
160 | > remote: # post-receive hook Z | |
161 | > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/main/topic Z | |
162 | > To <URL/of/upstream.git> | |
12d6991c | 163 | > HEAD:refs/for/main/topic <COMMIT-B>..<COMMIT-A> |
2bafb3d7 | 164 | > Done |
15d3af5e JX |
165 | EOF |
166 | test_cmp expect actual | |
167 | ' | |
168 | ||
169 | test_expect_success "setup proc-receive hook (option old-oid and new-oid, $PROTOCOL/porcelain)" ' | |
c39176b1 | 170 | test_hook -C "$upstream" --clobber proc-receive <<-EOF |
15d3af5e JX |
171 | printf >&2 "# proc-receive hook\n" |
172 | test-tool proc-receive -v \ | |
8f0a2645 | 173 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
174 | -r "option old-oid $A" \ |
175 | -r "option new-oid $B" | |
176 | EOF | |
177 | ' | |
178 | ||
8f0a2645 JS |
179 | # Refs of upstream : main(A) |
180 | # Refs of workbench: main(A) tags/v123 | |
181 | # git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) | |
15d3af5e JX |
182 | test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL/porcelain)" ' |
183 | git -C workbench push --porcelain origin \ | |
8f0a2645 | 184 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
185 | >out 2>&1 && |
186 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
187 | format_and_save_expect <<-EOF && |
188 | > remote: # pre-receive hook Z | |
189 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
190 | > remote: # proc-receive hook Z | |
191 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
192 | > remote: proc-receive> ok refs/for/main/topic Z | |
193 | > remote: proc-receive> option old-oid <COMMIT-A> Z | |
194 | > remote: proc-receive> option new-oid <COMMIT-B> Z | |
195 | > remote: # post-receive hook Z | |
196 | > remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/main/topic Z | |
197 | > To <URL/of/upstream.git> | |
12d6991c | 198 | > HEAD:refs/for/main/topic <COMMIT-A>..<COMMIT-B> |
2bafb3d7 | 199 | > Done |
15d3af5e JX |
200 | EOF |
201 | test_cmp expect actual | |
202 | ' | |
203 | ||
204 | test_expect_success "setup proc-receive hook (report with multiple rewrites, $PROTOCOL/porcelain)" ' | |
c39176b1 | 205 | test_hook -C "$upstream" --clobber proc-receive <<-EOF |
15d3af5e JX |
206 | printf >&2 "# proc-receive hook\n" |
207 | test-tool proc-receive -v \ | |
208 | -r "ok refs/for/a/b/c/topic" \ | |
209 | -r "ok refs/for/next/topic" \ | |
210 | -r "option refname refs/pull/123/head" \ | |
8f0a2645 | 211 | -r "ok refs/for/main/topic" \ |
15d3af5e JX |
212 | -r "option refname refs/pull/124/head" \ |
213 | -r "option old-oid $B" \ | |
214 | -r "option forced-update" \ | |
215 | -r "option new-oid $A" | |
216 | ||
217 | EOF | |
218 | ' | |
219 | ||
8f0a2645 JS |
220 | # Refs of upstream : main(A) |
221 | # Refs of workbench: main(A) tags/v123 | |
222 | # git push : refs/for/next/topic(A) refs/for/a/b/c/topic(A) refs/for/main/topic(A) | |
15d3af5e JX |
223 | test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porcelain)" ' |
224 | git -C workbench push --porcelain origin \ | |
225 | HEAD:refs/for/next/topic \ | |
226 | HEAD:refs/for/a/b/c/topic \ | |
8f0a2645 | 227 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
228 | >out 2>&1 && |
229 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
230 | format_and_save_expect <<-EOF && |
231 | > remote: # pre-receive hook Z | |
232 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic Z | |
233 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic Z | |
234 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
235 | > remote: # proc-receive hook Z | |
236 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic Z | |
237 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic Z | |
238 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
239 | > remote: proc-receive> ok refs/for/a/b/c/topic Z | |
240 | > remote: proc-receive> ok refs/for/next/topic Z | |
241 | > remote: proc-receive> option refname refs/pull/123/head Z | |
242 | > remote: proc-receive> ok refs/for/main/topic Z | |
243 | > remote: proc-receive> option refname refs/pull/124/head Z | |
244 | > remote: proc-receive> option old-oid <COMMIT-B> Z | |
245 | > remote: proc-receive> option forced-update Z | |
246 | > remote: proc-receive> option new-oid <COMMIT-A> Z | |
247 | > remote: # post-receive hook Z | |
248 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head Z | |
249 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic Z | |
250 | > remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head Z | |
251 | > To <URL/of/upstream.git> | |
252 | > * HEAD:refs/pull/123/head [new reference] | |
253 | > * HEAD:refs/for/a/b/c/topic [new reference] | |
12d6991c | 254 | > + HEAD:refs/pull/124/head <COMMIT-B>...<COMMIT-A> (forced update) |
2bafb3d7 | 255 | > Done |
15d3af5e JX |
256 | EOF |
257 | test_cmp expect actual && | |
258 | ||
822ee894 | 259 | test_cmp_refs -C "$upstream" <<-EOF |
8f0a2645 | 260 | <COMMIT-A> refs/heads/main |
15d3af5e | 261 | EOF |
15d3af5e | 262 | ' |