interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t5411 / test-0026-push-options.sh

133 lines · 4513 bytes Raw Blame History
1test_expect_success "setup proc-receive hook and disable push-options ($PROTOCOL)" '
2 git -C "$upstream" config receive.advertisePushOptions false &&
3 test_hook -C "$upstream" --clobber proc-receive <<-\EOF
4 printf >&2 "# proc-receive hook\n"
5 test-tool proc-receive -v \
6 -r "ok refs/for/main/topic"
7 EOF
8'
9
10# Refs of upstream : main(A)
11# Refs of workbench: main(A) tags/v123
12# git push -o ... : refs/for/main/topic
13test_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 \
18 HEAD:refs/for/main/topic \
19 >out-$test_count 2>&1 &&
20 make_user_friendly_and_stable_output <out-$test_count >actual &&
21 test_grep "fatal: the receiving end does not support push options" \
22 actual &&
23
24 test_cmp_refs -C "$upstream" <<-EOF
25 <COMMIT-A> refs/heads/main
26 EOF
27'
28
29test_expect_success "enable push options ($PROTOCOL)" '
30 git -C "$upstream" config receive.advertisePushOptions true
31'
32
33test_expect_success "setup version=0 for proc-receive hook ($PROTOCOL)" '
34 test_hook -C "$upstream" --clobber proc-receive <<-\EOF
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
45test_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 &&
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
68 EOF
69 test_cmp expect actual &&
70
71 test_cmp_refs -C "$upstream" <<-EOF
72 <COMMIT-A> refs/heads/main
73 <COMMIT-A> refs/heads/next
74 EOF
75'
76
77test_expect_success "restore proc-receive hook ($PROTOCOL)" '
78 test_hook -C "$upstream" --clobber proc-receive <<-\EOF
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
87test_expect_success "cleanup ($PROTOCOL)" '
88 git -C "$upstream" update-ref -d refs/heads/next
89'
90
91# Refs of upstream : main(A)
92# Refs of workbench: main(A) tags/v123
93# git push -o ... : next(A) refs/for/main/topic
94test_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 \
101 HEAD:refs/for/main/topic \
102 >out 2>&1 &&
103 make_user_friendly_and_stable_output <out >actual &&
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
120 EOF
121 test_cmp expect actual &&
122
123 test_cmp_refs -C "$upstream" <<-EOF
124 <COMMIT-A> refs/heads/main
125 <COMMIT-A> refs/heads/next
126 EOF
127'
128
129# Refs of upstream : main(A) next(A)
130# Refs of workbench: main(A) tags/v123
131test_expect_success "cleanup ($PROTOCOL)" '
132 git -C "$upstream" update-ref -d refs/heads/next
133'