]>
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 && | |
3 | write_script "$upstream/hooks/proc-receive" <<-EOF | |
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 \ |
15d3af5e JX |
19 | >out 2>&1 && |
20 | make_user_friendly_and_stable_output <out >actual && | |
21 | test_i18ngrep "fatal: the receiving end does not support push options" \ | |
22 | actual && | |
23 | git -C "$upstream" show-ref >out && | |
24 | make_user_friendly_and_stable_output <out >actual && | |
25 | cat >expect <<-EOF && | |
a9568dba | 26 | <COMMIT-A> refs/heads/main |
15d3af5e JX |
27 | EOF |
28 | test_cmp expect actual | |
29 | ' | |
30 | ||
31 | test_expect_success "enable push options ($PROTOCOL)" ' | |
32 | git -C "$upstream" config receive.advertisePushOptions true | |
33 | ' | |
34 | ||
80ffeb94 JX |
35 | test_expect_success "setup version=0 for proc-receive hook ($PROTOCOL)" ' |
36 | write_script "$upstream/hooks/proc-receive" <<-EOF | |
37 | printf >&2 "# proc-receive hook\n" | |
38 | test-tool proc-receive -v \ | |
39 | --version 0 \ | |
40 | -r "ok refs/for/main/topic" | |
41 | EOF | |
42 | ' | |
43 | ||
44 | # Refs of upstream : main(A) | |
45 | # Refs of workbench: main(A) tags/v123 | |
46 | # git push -o ... : next(A) refs/for/main/topic | |
47 | test_expect_success "proc-receive: ignore push-options for version 0 ($PROTOCOL)" ' | |
48 | git -C workbench push \ | |
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 && | |
57 | cat >expect <<-EOF && | |
58 | remote: # pre-receive hook | |
59 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next | |
60 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic | |
61 | remote: # proc-receive hook | |
62 | remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic | |
63 | remote: proc-receive> ok refs/for/main/topic | |
64 | remote: # post-receive hook | |
65 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next | |
66 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic | |
67 | To <URL/of/upstream.git> | |
68 | * [new branch] HEAD -> next | |
69 | * [new reference] HEAD -> refs/for/main/topic | |
70 | EOF | |
71 | test_cmp expect actual && | |
72 | git -C "$upstream" show-ref >out && | |
73 | make_user_friendly_and_stable_output <out >actual && | |
74 | cat >expect <<-EOF && | |
75 | <COMMIT-A> refs/heads/main | |
76 | <COMMIT-A> refs/heads/next | |
77 | EOF | |
78 | test_cmp expect actual | |
79 | ' | |
80 | ||
81 | test_expect_success "restore proc-receive hook ($PROTOCOL)" ' | |
82 | write_script "$upstream/hooks/proc-receive" <<-EOF | |
83 | printf >&2 "# proc-receive hook\n" | |
84 | test-tool proc-receive -v \ | |
85 | -r "ok refs/for/main/topic" | |
86 | EOF | |
87 | ' | |
88 | ||
89 | # Refs of upstream : main(A) next(A) | |
90 | # Refs of workbench: main(A) tags/v123 | |
91 | test_expect_success "cleanup ($PROTOCOL)" ' | |
92 | git -C "$upstream" update-ref -d refs/heads/next | |
93 | ' | |
94 | ||
a9568dba JS |
95 | # Refs of upstream : main(A) |
96 | # Refs of workbench: main(A) tags/v123 | |
97 | # git push -o ... : next(A) refs/for/main/topic | |
15d3af5e JX |
98 | test_expect_success "proc-receive: push with options ($PROTOCOL)" ' |
99 | git -C workbench push \ | |
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 && | |
108 | cat >expect <<-EOF && | |
109 | remote: # pre-receive hook | |
110 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next | |
a9568dba | 111 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
15d3af5e JX |
112 | remote: # proc-receive hook |
113 | remote: proc-receive: atomic push_options | |
a9568dba | 114 | remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
15d3af5e JX |
115 | remote: proc-receive< issue=123 |
116 | remote: proc-receive< reviewer=user1 | |
a9568dba | 117 | remote: proc-receive> ok refs/for/main/topic |
15d3af5e JX |
118 | remote: # post-receive hook |
119 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next | |
a9568dba | 120 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/main/topic |
15d3af5e JX |
121 | To <URL/of/upstream.git> |
122 | * [new branch] HEAD -> next | |
a9568dba | 123 | * [new reference] HEAD -> refs/for/main/topic |
15d3af5e JX |
124 | EOF |
125 | test_cmp expect actual && | |
126 | git -C "$upstream" show-ref >out && | |
127 | make_user_friendly_and_stable_output <out >actual && | |
128 | cat >expect <<-EOF && | |
a9568dba | 129 | <COMMIT-A> refs/heads/main |
15d3af5e JX |
130 | <COMMIT-A> refs/heads/next |
131 | EOF | |
132 | test_cmp expect actual | |
133 | ' | |
134 | ||
a9568dba JS |
135 | # Refs of upstream : main(A) next(A) |
136 | # Refs of workbench: main(A) tags/v123 | |
15d3af5e JX |
137 | test_expect_success "cleanup ($PROTOCOL)" ' |
138 | git -C "$upstream" update-ref -d refs/heads/next | |
139 | ' |