]>
Commit | Line | Data |
---|---|---|
15d3af5e JX |
1 | test_expect_success "setup proc-receive hook and disable push-options ($PROTOCOL/porcelain)" ' |
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 \ | |
6 | -r "ok refs/for/master/topic" | |
7 | EOF | |
8 | ' | |
9 | ||
10 | # Refs of upstream : master(A) | |
11 | # Refs of workbench: master(A) tags/v123 | |
12 | # git push -o ... : refs/for/master/topic | |
13 | test_expect_success "proc-receive: not support push options ($PROTOCOL/porcelain)" ' | |
14 | test_must_fail git -C workbench push \ | |
15 | --porcelain \ | |
16 | -o issue=123 \ | |
17 | -o reviewer=user1 \ | |
18 | origin \ | |
19 | HEAD:refs/for/master/topic \ | |
20 | >out 2>&1 && | |
21 | make_user_friendly_and_stable_output <out >actual && | |
22 | test_i18ngrep "fatal: the receiving end does not support push options" \ | |
23 | actual && | |
24 | git -C "$upstream" show-ref >out && | |
25 | make_user_friendly_and_stable_output <out >actual && | |
26 | cat >expect <<-EOF && | |
27 | <COMMIT-A> refs/heads/master | |
28 | EOF | |
29 | test_cmp expect actual | |
30 | ' | |
31 | ||
32 | test_expect_success "enable push options ($PROTOCOL/porcelain)" ' | |
33 | git -C "$upstream" config receive.advertisePushOptions true | |
34 | ' | |
35 | ||
36 | # Refs of upstream : master(A) | |
37 | # Refs of workbench: master(A) tags/v123 | |
38 | # git push -o ... : next(A) refs/for/master/topic | |
39 | test_expect_success "proc-receive: push with options ($PROTOCOL/porcelain)" ' | |
40 | git -C workbench push \ | |
41 | --porcelain \ | |
42 | --atomic \ | |
43 | -o issue=123 \ | |
44 | -o reviewer=user1 \ | |
45 | origin \ | |
46 | HEAD:refs/heads/next \ | |
47 | HEAD:refs/for/master/topic \ | |
48 | >out 2>&1 && | |
49 | make_user_friendly_and_stable_output <out >actual && | |
50 | cat >expect <<-EOF && | |
51 | remote: # pre-receive hook | |
52 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/heads/next | |
53 | remote: pre-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic | |
54 | remote: # proc-receive hook | |
55 | remote: proc-receive: atomic push_options | |
56 | remote: proc-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic | |
57 | remote: proc-receive< issue=123 | |
58 | remote: proc-receive< reviewer=user1 | |
59 | remote: proc-receive> ok refs/for/master/topic | |
60 | remote: # post-receive hook | |
61 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/heads/next | |
62 | remote: post-receive< <ZERO-OID> <COMMIT-A> refs/for/master/topic | |
63 | To <URL/of/upstream.git> | |
64 | * HEAD:refs/heads/next [new branch] | |
65 | * HEAD:refs/for/master/topic [new reference] | |
66 | Done | |
67 | EOF | |
68 | test_cmp expect actual && | |
69 | git -C "$upstream" show-ref >out && | |
70 | make_user_friendly_and_stable_output <out >actual && | |
71 | cat >expect <<-EOF && | |
72 | <COMMIT-A> refs/heads/master | |
73 | <COMMIT-A> refs/heads/next | |
74 | EOF | |
75 | test_cmp expect actual | |
76 | ' | |
77 | ||
78 | # Refs of upstream : master(A) next(A) | |
79 | # Refs of workbench: master(A) tags/v123 | |
80 | test_expect_success "cleanup ($PROTOCOL/porcelain)" ' | |
81 | git -C "$upstream" update-ref -d refs/heads/next | |
82 | ' |