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