]>
Commit | Line | Data |
---|---|---|
15d3af5e JX |
1 | test_expect_success "setup proc-receive hook and disable push-options ($PROTOCOL/porcelain)" ' |
2 | git -C "$upstream" config receive.advertisePushOptions false && | |
c39176b1 | 3 | test_hook -C "$upstream" --clobber proc-receive <<-\EOF |
15d3af5e JX |
4 | printf >&2 "# proc-receive hook\n" |
5 | test-tool proc-receive -v \ | |
a9568dba | 6 | -r "ok refs/for/main/topic" |
15d3af5e JX |
7 | EOF |
8 | ' | |
9 | ||
a9568dba JS |
10 | # Refs of upstream : main(A) |
11 | # Refs of workbench: main(A) tags/v123 | |
12 | # git push -o ... : refs/for/main/topic | |
15d3af5e JX |
13 | test_expect_success "proc-receive: not support push options ($PROTOCOL/porcelain)" ' |
14 | test_must_fail git -C workbench push \ | |
15 | --porcelain \ | |
16 | -o issue=123 \ | |
17 | -o reviewer=user1 \ | |
18 | origin \ | |
a9568dba | 19 | HEAD:refs/for/main/topic \ |
8388a64c JX |
20 | >out-$test_count 2>&1 && |
21 | make_user_friendly_and_stable_output <out-$test_count >actual && | |
6789275d | 22 | test_grep "fatal: the receiving end does not support push options" \ |
15d3af5e | 23 | actual && |
822ee894 JX |
24 | |
25 | test_cmp_refs -C "$upstream" <<-EOF | |
a9568dba | 26 | <COMMIT-A> refs/heads/main |
15d3af5e | 27 | EOF |
15d3af5e JX |
28 | ' |
29 | ||
30 | test_expect_success "enable push options ($PROTOCOL/porcelain)" ' | |
31 | git -C "$upstream" config receive.advertisePushOptions true | |
32 | ' | |
33 | ||
80ffeb94 | 34 | test_expect_success "setup version=0 for proc-receive hook ($PROTOCOL/porcelain)" ' |
c39176b1 | 35 | test_hook -C "$upstream" --clobber proc-receive <<-\EOF |
80ffeb94 JX |
36 | printf >&2 "# proc-receive hook\n" |
37 | test-tool proc-receive -v \ | |
38 | --version 0 \ | |
39 | -r "ok refs/for/main/topic" | |
40 | EOF | |
41 | ' | |
42 | ||
43 | # Refs of upstream : main(A) | |
44 | # Refs of workbench: main(A) tags/v123 | |
45 | # git push -o ... : next(A) refs/for/main/topic | |
46 | test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL/porcelain)" ' | |
47 | git -C workbench push \ | |
48 | --porcelain \ | |
49 | --atomic \ | |
50 | -o issue=123 \ | |
51 | -o reviewer=user1 \ | |
52 | origin \ | |
53 | HEAD:refs/heads/next \ | |
54 | HEAD:refs/for/main/topic \ | |
55 | >out 2>&1 && | |
56 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
57 | format_and_save_expect <<-EOF && |
58 | > remote: # pre-receive hook Z | |
59 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z | |
60 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
61 | > remote: # proc-receive hook Z | |
62 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
63 | > remote: proc-receive> ok refs/for/main/topic Z | |
64 | > remote: # post-receive hook Z | |
65 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z | |
66 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
67 | > To <URL/of/upstream.git> | |
68 | > * HEAD:refs/heads/next [new branch] | |
69 | > * HEAD:refs/for/main/topic [new reference] | |
70 | > Done | |
80ffeb94 JX |
71 | EOF |
72 | test_cmp expect actual && | |
822ee894 JX |
73 | |
74 | test_cmp_refs -C "$upstream" <<-EOF | |
80ffeb94 JX |
75 | <COMMIT-A> refs/heads/main |
76 | <COMMIT-A> refs/heads/next | |
77 | EOF | |
80ffeb94 JX |
78 | ' |
79 | ||
80 | test_expect_success "restore proc-receive hook ($PROTOCOL/porcelain)" ' | |
c39176b1 | 81 | test_hook -C "$upstream" --clobber proc-receive <<-\EOF |
80ffeb94 JX |
82 | printf >&2 "# proc-receive hook\n" |
83 | test-tool proc-receive -v \ | |
84 | -r "ok refs/for/main/topic" | |
85 | EOF | |
86 | ' | |
87 | ||
88 | # Refs of upstream : main(A) next(A) | |
89 | # Refs of workbench: main(A) tags/v123 | |
90 | test_expect_success "cleanup ($PROTOCOL/porcelain)" ' | |
91 | git -C "$upstream" update-ref -d refs/heads/next | |
92 | ' | |
93 | ||
a9568dba JS |
94 | # Refs of upstream : main(A) |
95 | # Refs of workbench: main(A) tags/v123 | |
96 | # git push -o ... : next(A) refs/for/main/topic | |
15d3af5e JX |
97 | test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" ' |
98 | git -C workbench push \ | |
99 | --porcelain \ | |
100 | --atomic \ | |
101 | -o issue=123 \ | |
102 | -o reviewer=user1 \ | |
103 | origin \ | |
104 | HEAD:refs/heads/next \ | |
a9568dba | 105 | HEAD:refs/for/main/topic \ |
15d3af5e JX |
106 | >out 2>&1 && |
107 | make_user_friendly_and_stable_output <out >actual && | |
2bafb3d7 JX |
108 | format_and_save_expect <<-EOF && |
109 | > remote: # pre-receive hook Z | |
110 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z | |
111 | > remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
112 | > remote: # proc-receive hook Z | |
113 | > remote: proc-receive: atomic push_options Z | |
114 | > remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
115 | > remote: proc-receive< issue=123 Z | |
116 | > remote: proc-receive< reviewer=user1 Z | |
117 | > remote: proc-receive> ok refs/for/main/topic Z | |
118 | > remote: # post-receive hook Z | |
119 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next Z | |
120 | > remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic Z | |
121 | > To <URL/of/upstream.git> | |
122 | > * HEAD:refs/heads/next [new branch] | |
123 | > * HEAD:refs/for/main/topic [new reference] | |
124 | > Done | |
15d3af5e JX |
125 | EOF |
126 | test_cmp expect actual && | |
822ee894 JX |
127 | |
128 | test_cmp_refs -C "$upstream" <<-EOF | |
a9568dba | 129 | <COMMIT-A> refs/heads/main |
15d3af5e JX |
130 | <COMMIT-A> refs/heads/next |
131 | EOF | |
15d3af5e JX |
132 | ' |
133 | ||
a9568dba JS |
134 | # Refs of upstream : main(A) next(A) |
135 | # Refs of workbench: main(A) tags/v123 | |
15d3af5e JX |
136 | test_expect_success "cleanup ($PROTOCOL/porcelain)" ' |
137 | git -C "$upstream" update-ref -d refs/heads/next | |
138 | ' |