blob: 78d0b63876eaf5320afbc426b31325f8ba6e311e [file] [log] [blame]
Jiang Xin15d3af52020-08-27 11:45:44 -04001test_expect_success "setup proc-receive hook (ft, $PROTOCOL)" '
Ævar Arnfjörð Bjarmasonc39176b2022-03-17 11:13:17 +01002 test_hook -C "$upstream" --clobber proc-receive <<-\EOF
Jiang Xin15d3af52020-08-27 11:45:44 -04003 printf >&2 "# proc-receive hook\n"
4 test-tool proc-receive -v \
Johannes Schindelin8f0a2642020-10-31 19:46:01 +00005 -r "ok refs/for/main/topic" \
Jiang Xin15d3af52020-08-27 11:45:44 -04006 -r "option fall-through"
7 EOF
8'
9
Johannes Schindelin8f0a2642020-10-31 19:46:01 +000010# Refs of upstream : main(A)
11# Refs of workbench: main(A) tags/v123
12# git push : refs/for/main/topic(B)
Andrew Kreimerf56f9d62024-10-24 14:47:20 +030013test_expect_success "proc-receive: fall through, let receive-pack to execute ($PROTOCOL)" '
Jiang Xin15d3af52020-08-27 11:45:44 -040014 git -C workbench push origin \
Johannes Schindelin8f0a2642020-10-31 19:46:01 +000015 $B:refs/for/main/topic \
Jiang Xin15d3af52020-08-27 11:45:44 -040016 >out 2>&1 &&
17 make_user_friendly_and_stable_output <out >actual &&
Jiang Xin2bafb3d2021-06-17 11:17:25 +080018 format_and_save_expect <<-EOF &&
19 > remote: # pre-receive hook Z
20 > remote: pre-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic Z
21 > remote: # proc-receive hook Z
22 > remote: proc-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic Z
23 > remote: proc-receive> ok refs/for/main/topic Z
24 > remote: proc-receive> option fall-through Z
25 > remote: # post-receive hook Z
26 > remote: post-receive< <ZERO-OID> <COMMIT-B> refs/for/main/topic Z
27 > To <URL/of/upstream.git>
28 > * [new reference] <COMMIT-B> -> refs/for/main/topic
Jiang Xin15d3af52020-08-27 11:45:44 -040029 EOF
30 test_cmp expect actual &&
Jiang Xin822ee892021-01-20 21:53:31 -050031
32 test_cmp_refs -C "$upstream" <<-EOF
Johannes Schindelin8f0a2642020-10-31 19:46:01 +000033 <COMMIT-B> refs/for/main/topic
34 <COMMIT-A> refs/heads/main
Jiang Xin15d3af52020-08-27 11:45:44 -040035 EOF
Jiang Xin15d3af52020-08-27 11:45:44 -040036'
37
Johannes Schindelin8f0a2642020-10-31 19:46:01 +000038# Refs of upstream : main(A) refs/for/main/topic(A)
39# Refs of workbench: main(A) tags/v123
Jiang Xin15d3af52020-08-27 11:45:44 -040040test_expect_success "cleanup ($PROTOCOL)" '
Johannes Schindelin8f0a2642020-10-31 19:46:01 +000041 git -C "$upstream" update-ref -d refs/for/main/topic
Jiang Xin15d3af52020-08-27 11:45:44 -040042'