diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t5411-proc-receive-hook.sh | 9 | ||||
-rw-r--r-- | t/t5411/once-0010-report-status-v1.sh | 90 | ||||
-rw-r--r-- | t/t5411/test-0032-report-with-options.sh | 14 | ||||
-rw-r--r-- | t/t5411/test-0033-report-with-options--porcelain.sh | 14 | ||||
-rw-r--r-- | t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh | 11 | ||||
-rw-r--r-- | t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh | 11 | ||||
-rw-r--r-- | t/t5411/test-0038-report-mixed-refs.sh | 2 | ||||
-rw-r--r-- | t/t5411/test-0039-report-mixed-refs--porcelain.sh | 2 |
8 files changed, 131 insertions, 22 deletions
diff --git a/t/t5411-proc-receive-hook.sh b/t/t5411-proc-receive-hook.sh index 3a684353a8..746487286f 100755 --- a/t/t5411-proc-receive-hook.sh +++ b/t/t5411-proc-receive-hook.sh @@ -78,6 +78,15 @@ run_proc_receive_hook_test() { # Initialize the upstream repository and local workbench. setup_upstream_and_workbench +# Load test cases that only need to be executed once. +for t in "$TEST_DIRECTORY"/t5411/once-*.sh +do + . "$t" +done + +# Initialize the upstream repository and local workbench. +setup_upstream_and_workbench + # Run test cases for 'proc-receive' hook on local file protocol. run_proc_receive_hook_test local diff --git a/t/t5411/once-0010-report-status-v1.sh b/t/t5411/once-0010-report-status-v1.sh new file mode 100644 index 0000000000..bf410dc418 --- /dev/null +++ b/t/t5411/once-0010-report-status-v1.sh @@ -0,0 +1,90 @@ +test_expect_success "setup proc-receive hook" ' + write_script "$upstream/hooks/proc-receive" <<-EOF + printf >&2 "# proc-receive hook\n" + test-tool proc-receive -v \ + -r "ok refs/for/master/topic1" \ + -r "option fall-through" \ + -r "ok refs/for/master/topic2" \ + -r "option refname refs/for/changes/23/123/1" \ + -r "option new-oid $A" \ + -r "ok refs/for/master/topic2" \ + -r "option refname refs/for/changes/24/124/2" \ + -r "option old-oid $B" \ + -r "option new-oid $A" \ + -r "option forced-update" \ + -r "ng refs/for/next/topic target branch not exist" + EOF +' + +# Refs of upstream : master(A) +# Refs of workbench: master(A) tags/v123 +# git push : (B) refs/for/master/topic1(A) foo(A) refs/for/next/topic(A) refs/for/master/topic2(A) +test_expect_success "proc-receive: report status v1" ' + { + if test -z "$GIT_DEFAULT_HASH" || test "$GIT_DEFAULT_HASH" = "sha1" + then + printf "%s %s refs/heads/master\0report-status\n" \ + $A $B | packetize + else + printf "%s %s refs/heads/master\0report-status object-format=$GIT_DEFAULT_HASH\n" \ + $A $B | packetize + fi && + printf "%s %s refs/for/master/topic1\n" \ + $ZERO_OID $A | packetize && + printf "%s %s refs/heads/foo\n" \ + $ZERO_OID $A | packetize && + printf "%s %s refs/for/next/topic\n" \ + $ZERO_OID $A | packetize && + printf "%s %s refs/for/master/topic2\n" \ + $ZERO_OID $A | packetize && + printf 0000 && + printf "" | git -C "$upstream" pack-objects --stdout + } | git receive-pack "$upstream" --stateless-rpc \ + >out 2>&1 && + make_user_friendly_and_stable_output <out >actual && + cat >expect <<-EOF && + # pre-receive hook + pre-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1 + pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo + pre-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic + pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic2 + # proc-receive hook + proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1 + proc-receive< <ZERO-OID> <COMMIT-A> refs/for/next/topic + proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic2 + proc-receive> ok refs/for/master/topic1 + proc-receive> option fall-through + proc-receive> ok refs/for/master/topic2 + proc-receive> option refname refs/for/changes/23/123/1 + proc-receive> option new-oid <COMMIT-A> + proc-receive> ok refs/for/master/topic2 + proc-receive> option refname refs/for/changes/24/124/2 + proc-receive> option old-oid <COMMIT-B> + proc-receive> option new-oid <COMMIT-A> + proc-receive> option forced-update + proc-receive> ng refs/for/next/topic target branch not exist + 000eunpack ok + 0019ok refs/heads/master + 001eok refs/for/master/topic1 + 0016ok refs/heads/foo + 0033ng refs/for/next/topic target branch not exist + 001eok refs/for/master/topic2 + 0000# post-receive hook + post-receive< <COMMIT-A> <COMMIT-B> refs/heads/master + post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic1 + post-receive< <ZERO-OID> <COMMIT-A> refs/heads/foo + post-receive< <ZERO-OID> <COMMIT-A> refs/for/changes/23/123/1 + post-receive< <COMMIT-B> <COMMIT-A> refs/for/changes/24/124/2 + EOF + test_cmp expect actual && + + git -C "$upstream" show-ref >out && + make_user_friendly_and_stable_output <out >actual && + cat >expect <<-EOF && + <COMMIT-A> refs/for/master/topic1 + <COMMIT-A> refs/heads/foo + <COMMIT-B> refs/heads/master + EOF + test_cmp expect actual +' diff --git a/t/t5411/test-0032-report-with-options.sh b/t/t5411/test-0032-report-with-options.sh index c559c207fa..b77b78c49f 100644 --- a/t/t5411/test-0032-report-with-options.sh +++ b/t/t5411/test-0032-report-with-options.sh @@ -56,7 +56,7 @@ test_expect_success "proc-receive: report option refname ($PROTOCOL)" ' remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + * [new reference] HEAD -> refs/pull/123/head EOF test_cmp expect actual ' @@ -89,7 +89,7 @@ test_expect_success "proc-receive: report option refname and forced-update ($PRO remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + * [new reference] HEAD -> refs/pull/123/head EOF test_cmp expect actual ' @@ -123,7 +123,7 @@ test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL) remote: # post-receive hook remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/123/head To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + <OID-B>..<OID-A> HEAD -> refs/pull/123/head EOF test_cmp expect actual ' @@ -155,7 +155,7 @@ test_expect_success "proc-receive: report option old-oid ($PROTOCOL)" ' remote: # post-receive hook remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/master/topic To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + <OID-B>..<OID-A> HEAD -> refs/for/master/topic EOF test_cmp expect actual ' @@ -189,7 +189,7 @@ test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL) remote: # post-receive hook remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + <OID-A>..<OID-B> HEAD -> refs/for/master/topic EOF test_cmp expect actual ' @@ -241,9 +241,9 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL)" ' remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/next/topic + * [new reference] HEAD -> refs/pull/123/head * [new reference] HEAD -> refs/for/a/b/c/topic - * [new reference] HEAD -> refs/for/master/topic + + <OID-B>...<OID-A> HEAD -> refs/pull/124/head (forced update) EOF test_cmp expect actual && diff --git a/t/t5411/test-0033-report-with-options--porcelain.sh b/t/t5411/test-0033-report-with-options--porcelain.sh index ea9312234e..1fe352b686 100644 --- a/t/t5411/test-0033-report-with-options--porcelain.sh +++ b/t/t5411/test-0033-report-with-options--porcelain.sh @@ -57,7 +57,7 @@ test_expect_success "proc-receive: report option refname ($PROTOCOL/porcelain)" remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + * HEAD:refs/pull/123/head [new reference] Done EOF test_cmp expect actual @@ -92,7 +92,7 @@ test_expect_success "proc-receive: report option refname and forced-update ($PRO remote: # post-receive hook remote: post-receive< <ZERO-OID> <COMMIT-A> refs/pull/123/head To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + * HEAD:refs/pull/123/head [new reference] Done EOF test_cmp expect actual @@ -127,7 +127,7 @@ test_expect_success "proc-receive: report option refname and old-oid ($PROTOCOL/ remote: # post-receive hook remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/123/head To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + HEAD:refs/pull/123/head <OID-B>..<OID-A> Done EOF test_cmp expect actual @@ -160,7 +160,7 @@ test_expect_success "proc-receive: report option old-oid ($PROTOCOL/porcelain)" remote: # post-receive hook remote: post-receive< <COMMIT-B> <COMMIT-A> refs/for/master/topic To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + HEAD:refs/for/master/topic <OID-B>..<OID-A> Done EOF test_cmp expect actual @@ -195,7 +195,7 @@ test_expect_success "proc-receive: report option old-oid and new-oid ($PROTOCOL/ remote: # post-receive hook remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + HEAD:refs/for/master/topic <OID-A>..<OID-B> Done EOF test_cmp expect actual @@ -249,9 +249,9 @@ test_expect_success "proc-receive: report with multiple rewrites ($PROTOCOL/porc remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/a/b/c/topic remote: post-receive< <COMMIT-B> <COMMIT-A> refs/pull/124/head To <URL/of/upstream.git> - * HEAD:refs/for/next/topic [new reference] + * HEAD:refs/pull/123/head [new reference] * HEAD:refs/for/a/b/c/topic [new reference] - * HEAD:refs/for/master/topic [new reference] + + HEAD:refs/pull/124/head <OID-B>...<OID-A> (forced update) Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh index 67cc4a8a4c..27d58edd14 100644 --- a/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh +++ b/t/t5411/test-0036-report-multi-rewrite-for-one-ref.sh @@ -45,7 +45,9 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1 To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + <OID-A>..<OID-B> HEAD -> refs/for/master/topic + * [new reference] HEAD -> refs/changes/24/124/1 + <OID-A>..<OID-B> HEAD -> refs/changes/25/125/1 EOF test_cmp expect actual && git -C "$upstream" show-ref >out && @@ -105,7 +107,9 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1 To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + * [new reference] HEAD -> refs/changes/24/124/1 + <OID-A>..<OID-B> HEAD -> refs/for/master/topic + + <OID-B>...<OID-A> HEAD -> refs/changes/25/125/1 (forced update) EOF test_cmp expect actual && git -C "$upstream" show-ref >out && @@ -152,7 +156,8 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL)" ' remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/23/123/1 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/24/124/2 To <URL/of/upstream.git> - * [new reference] HEAD -> refs/for/master/topic + * [new reference] HEAD -> refs/changes/23/123/1 + <OID-A>..<OID-B> HEAD -> refs/changes/24/124/2 EOF test_cmp expect actual && git -C "$upstream" show-ref >out && diff --git a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh index 1dc8551bc6..77b5b22ed4 100644 --- a/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh +++ b/t/t5411/test-0037-report-multi-rewrite-for-one-ref--porcelain.sh @@ -45,7 +45,9 @@ test_expect_success "proc-receive: multiple rewrite for one ref, no refname for remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/24/124/1 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/25/125/1 To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + HEAD:refs/for/master/topic <OID-A>..<OID-B> + * HEAD:refs/changes/24/124/1 [new reference] + HEAD:refs/changes/25/125/1 <OID-A>..<OID-B> Done EOF test_cmp expect actual && @@ -106,7 +108,9 @@ test_expect_success "proc-receive: multiple rewrites for one ref, no refname for remote: post-receive< <COMMIT-A> <COMMIT-B> refs/for/master/topic remote: post-receive< <COMMIT-B> <COMMIT-A> refs/changes/25/125/1 To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + * HEAD:refs/changes/24/124/1 [new reference] + HEAD:refs/for/master/topic <OID-A>..<OID-B> + + HEAD:refs/changes/25/125/1 <OID-B>...<OID-A> (forced update) Done EOF test_cmp expect actual && @@ -154,7 +158,8 @@ test_expect_success "proc-receive: multiple rewrites for one ref ($PROTOCOL/porc remote: post-receive< <ZERO-OID> <COMMIT-A> refs/changes/23/123/1 remote: post-receive< <COMMIT-A> <COMMIT-B> refs/changes/24/124/2 To <URL/of/upstream.git> - * HEAD:refs/for/master/topic [new reference] + * HEAD:refs/changes/23/123/1 [new reference] + HEAD:refs/changes/24/124/2 <OID-A>..<OID-B> Done EOF test_cmp expect actual && diff --git a/t/t5411/test-0038-report-mixed-refs.sh b/t/t5411/test-0038-report-mixed-refs.sh index bfc8d586d6..a74a2cb449 100644 --- a/t/t5411/test-0038-report-mixed-refs.sh +++ b/t/t5411/test-0038-report-mixed-refs.sh @@ -60,7 +60,7 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL)" ' * [new branch] HEAD -> baz * [new reference] HEAD -> refs/for/next/topic2 * [new branch] HEAD -> foo - * [new reference] HEAD -> refs/for/master/topic + <OID-A>..<OID-B> HEAD -> refs/for/master/topic ! [remote rejected] HEAD -> refs/for/next/topic1 (fail to call Web API) ! [remote rejected] HEAD -> refs/for/next/topic3 (proc-receive failed to report status) EOF diff --git a/t/t5411/test-0039-report-mixed-refs--porcelain.sh b/t/t5411/test-0039-report-mixed-refs--porcelain.sh index 5d021a4837..e4baa13ea3 100644 --- a/t/t5411/test-0039-report-mixed-refs--porcelain.sh +++ b/t/t5411/test-0039-report-mixed-refs--porcelain.sh @@ -60,7 +60,7 @@ test_expect_success "proc-receive: report update of mixed refs ($PROTOCOL/porcel * HEAD:refs/heads/baz [new branch] * HEAD:refs/for/next/topic2 [new reference] * HEAD:refs/heads/foo [new branch] - * HEAD:refs/for/master/topic [new reference] + HEAD:refs/for/master/topic <OID-A>..<OID-B> ! HEAD:refs/for/next/topic1 [remote rejected] (fail to call Web API) ! HEAD:refs/for/next/topic3 [remote rejected] (proc-receive failed to report status) Done |