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