2020-08-27 15:45:43 +00:00
|
|
|
test_expect_success "setup pre-receive hook ($PROTOCOL/porcelain)" '
|
|
|
|
mv "$upstream/hooks/pre-receive" "$upstream/hooks/pre-receive.ok" &&
|
2022-03-17 10:13:17 +00:00
|
|
|
test_hook -C "$upstream" --clobber pre-receive <<-\EOF
|
2020-08-27 15:45:43 +00:00
|
|
|
exit 1
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2020-10-31 19:46:02 +00:00
|
|
|
# Refs of upstream : main(A)
|
|
|
|
# Refs of workbench: main(A) tags/v123
|
|
|
|
# git-push : main(B) next(A)
|
2020-08-27 15:45:43 +00:00
|
|
|
test_expect_success "git-push is declined ($PROTOCOL/porcelain)" '
|
|
|
|
test_must_fail git -C workbench push --porcelain origin \
|
2020-10-31 19:46:02 +00:00
|
|
|
$B:refs/heads/main \
|
2020-08-27 15:45:43 +00:00
|
|
|
HEAD:refs/heads/next \
|
2021-01-21 02:53:30 +00:00
|
|
|
>out-$test_count 2>&1 &&
|
|
|
|
make_user_friendly_and_stable_output <out-$test_count >actual &&
|
2021-06-17 03:17:25 +00:00
|
|
|
format_and_save_expect <<-EOF &&
|
|
|
|
> To <URL/of/upstream.git>
|
|
|
|
> ! <COMMIT-B>:refs/heads/main [remote rejected] (pre-receive hook declined)
|
|
|
|
> ! HEAD:refs/heads/next [remote rejected] (pre-receive hook declined)
|
2020-08-27 15:45:43 +00:00
|
|
|
Done
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual &&
|
2021-01-21 02:53:31 +00:00
|
|
|
|
|
|
|
test_cmp_refs -C "$upstream" <<-EOF
|
2020-10-31 19:46:02 +00:00
|
|
|
<COMMIT-A> refs/heads/main
|
2020-08-27 15:45:43 +00:00
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "cleanup ($PROTOCOL/porcelain)" '
|
|
|
|
mv "$upstream/hooks/pre-receive.ok" "$upstream/hooks/pre-receive"
|
|
|
|
'
|