1 test_expect_success "setup proc-receive hook (unknown version, $PROTOCOL/porcelain)" '
2 write_script "$upstream/hooks/proc-receive" <<-EOF
3 printf >&2 "# proc-receive hook\n"
4 test-tool proc-receive -v --version 2
8 # Refs of upstream : master(A)
9 # Refs of workbench: master(A) tags/v123
10 # git push : refs/for/master/topic(A)
11 test_expect_success "proc-receive: bad protocol (unknown version, $PROTOCOL/porcelain)" '
12 test_must_fail git -C workbench push --porcelain origin \
13 HEAD:refs/for/master/topic \
15 make_user_friendly_and_stable_output <out >actual &&
17 # Check status report for git-push
19 -e "/^To / { p; n; p; n; p; }" \
20 <actual >actual-report &&
22 To <URL/of/upstream.git>
23 ! HEAD:refs/for/master/topic [remote rejected] (fail to run proc-receive hook)
26 test_cmp expect actual-report &&
28 # Check error message from "receive-pack", but ignore unstable fatal error
29 # message ("remote: fatal: the remote end hung up unexpectedly") which
30 # is different from the remote HTTP server with different locale settings.
31 grep "^remote: error:" <actual >actual-error &&
33 remote: error: proc-receive version "2" is not supported
35 test_cmp expect actual-error &&
37 git -C "$upstream" show-ref >out &&
38 make_user_friendly_and_stable_output <out >actual &&
40 <COMMIT-A> refs/heads/master
42 test_cmp expect actual
45 test_expect_success "setup proc-receive hook (no report, $PROTOCOL/porcelain)" '
46 write_script "$upstream/hooks/proc-receive" <<-EOF
47 printf >&2 "# proc-receive hook\n"
48 test-tool proc-receive -v
52 # Refs of upstream : master(A)
53 # Refs of workbench: master(A) tags/v123
54 # git push : next(A) refs/for/master/topic(A)
55 test_expect_success "proc-receive: bad protocol (no report, $PROTOCOL/porcelain)" '
56 test_must_fail git -C workbench push --porcelain origin \
57 HEAD:refs/heads/next \
58 HEAD:refs/for/master/topic >out 2>&1 &&
59 make_user_friendly_and_stable_output <out >actual &&
61 remote: # pre-receive hook
62 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
63 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
64 remote: # proc-receive hook
65 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
66 remote: # post-receive hook
67 remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next
68 To <URL/of/upstream.git>
69 * HEAD:refs/heads/next [new branch]
70 ! HEAD:refs/for/master/topic [remote rejected] (proc-receive failed to report status)
73 test_cmp expect actual &&
74 git -C "$upstream" show-ref >out &&
75 make_user_friendly_and_stable_output <out >actual &&
77 <COMMIT-A> refs/heads/master
78 <COMMIT-A> refs/heads/next
80 test_cmp expect actual
83 # Refs of upstream : master(A) next(A)
84 # Refs of workbench: master(A) tags/v123
85 test_expect_success "cleanup ($PROTOCOL/porcelain)" '
86 git -C "$upstream" update-ref -d refs/heads/next
90 test_expect_success "setup proc-receive hook (no ref, $PROTOCOL/porcelain)" '
91 write_script "$upstream/hooks/proc-receive" <<-EOF
92 printf >&2 "# proc-receive hook\n"
93 test-tool proc-receive -v \
98 # Refs of upstream : master(A)
99 # Refs of workbench: master(A) tags/v123
100 # git push : refs/for/master/topic
101 test_expect_success "proc-receive: bad protocol (no ref, $PROTOCOL/porcelain)" '
102 test_must_fail git -C workbench push --porcelain origin \
103 HEAD:refs/for/master/topic\
105 make_user_friendly_and_stable_output <out >actual &&
106 cat >expect <<-EOF &&
107 remote: # pre-receive hook
108 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
109 remote: # proc-receive hook
110 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
111 remote: proc-receive> ok
112 remote: error: proc-receive reported incomplete status line: "ok"
113 To <URL/of/upstream.git>
114 ! HEAD:refs/for/master/topic [remote rejected] (proc-receive failed to report status)
117 test_cmp expect actual &&
118 git -C "$upstream" show-ref >out &&
119 make_user_friendly_and_stable_output <out >actual &&
120 cat >expect <<-EOF &&
121 <COMMIT-A> refs/heads/master
123 test_cmp expect actual
126 test_expect_success "setup proc-receive hook (unknown status, $PROTOCOL/porcelain)" '
127 write_script "$upstream/hooks/proc-receive" <<-EOF
128 printf >&2 "# proc-receive hook\n"
129 test-tool proc-receive -v \
130 -r "xx refs/for/master/topic"
134 # Refs of upstream : master(A)
135 # Refs of workbench: master(A) tags/v123
136 # git push : refs/for/master/topic
137 test_expect_success "proc-receive: bad protocol (unknown status, $PROTOCOL/porcelain)" '
138 test_must_fail git -C workbench push --porcelain origin \
139 HEAD:refs/for/master/topic \
141 make_user_friendly_and_stable_output <out >actual &&
142 cat >expect <<-EOF &&
143 remote: # pre-receive hook
144 remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
145 remote: # proc-receive hook
146 remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic
147 remote: proc-receive> xx refs/for/master/topic
148 remote: error: proc-receive reported bad status "xx" on ref "refs/for/master/topic"
149 To <URL/of/upstream.git>
150 ! HEAD:refs/for/master/topic [remote rejected] (proc-receive failed to report status)
153 test_cmp expect actual &&
154 git -C "$upstream" show-ref >out &&
155 make_user_friendly_and_stable_output <out >actual &&
156 cat >expect <<-EOF &&
157 <COMMIT-A> refs/heads/master
159 test_cmp expect actual