mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-06-27 20:33:44 +00:00
remove branches when closing a cascade PR from a fork
Fixes: https://code.forgejo.org/actions/cascading-pr/issues/17
This commit is contained in:
parent
09dc15f425
commit
417a1ecac9
2 changed files with 36 additions and 13 deletions
24
tests/run.sh
24
tests/run.sh
|
@ -110,6 +110,12 @@ function cascade_pull_request() {
|
|||
forgejo-curl.sh api_json ${options[url]}/api/v1/repos/user2/${repo}/pulls
|
||||
}
|
||||
|
||||
function branches_count() {
|
||||
local owner="$1" repo="$2"
|
||||
|
||||
forgejo-curl.sh api_json ${options[url]}/api/v1/repos/${owner}/${repo}/branches | jq '. | length'
|
||||
}
|
||||
|
||||
function create_branch1() {
|
||||
local owner=$1 repo=$2 modify=$3
|
||||
|
||||
|
@ -282,7 +288,9 @@ function branch_and_success() {
|
|||
create_branch1 user1 ${origin_repo}
|
||||
wait_success ${options[url]}/api/v1/repos/user1/${origin_repo} $(cat $TMPDIR/user1-${origin_repo}.sha)
|
||||
test $(cascade_pull_request_count ${destination_repo}) = 1
|
||||
# origin-branch-fail/.forgejo/workflows/test.yml has `close: true`
|
||||
has_no_cascade_pull_request ${destination_repo}
|
||||
test 1 = "$(branches_count user2 ${destination_repo})"
|
||||
}
|
||||
|
||||
function branch_and_fail() {
|
||||
|
@ -296,7 +304,9 @@ function branch_and_fail() {
|
|||
create_branch1 user1 ${origin_repo}
|
||||
wait_failure ${options[url]}/api/v1/repos/user1/${origin_repo} $(cat $TMPDIR/user1-${origin_repo}.sha)
|
||||
test $(cascade_pull_request_count ${destination_repo}) = 1
|
||||
has_no_cascade_pull_request ${destination_repo}
|
||||
# origin-branch-fail/.forgejo/workflows/test.yml has `close: false`
|
||||
has_cascade_pull_request ${destination_repo}
|
||||
test 2 = "$(branches_count user2 ${destination_repo})"
|
||||
}
|
||||
|
||||
function create_and_close() {
|
||||
|
@ -306,8 +316,10 @@ function create_and_close() {
|
|||
create_pull_request_case1 user1 user1 originrepo
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo $(cat $TMPDIR/user1-originrepo.sha)
|
||||
has_cascade_pull_request
|
||||
test 2 = "$(branches_count user2 destinationrepo)"
|
||||
close_pull_request originrepo
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo $(cat $TMPDIR/user1-originrepo.sha)
|
||||
test 1 = "$(branches_count user2 destinationrepo)"
|
||||
}
|
||||
|
||||
function taint_update() {
|
||||
|
@ -340,9 +352,11 @@ function create_and_merge() {
|
|||
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo $(cat $TMPDIR/user1-originrepo.sha)
|
||||
has_cascade_pull_request
|
||||
test 2 = "$(branches_count user2 destinationrepo)"
|
||||
merge_pull_request originrepo
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo $(cat $TMPDIR/user1-originrepo.sha)
|
||||
has_cascade_pull_request
|
||||
test 2 = "$(branches_count user2 destinationrepo)"
|
||||
}
|
||||
|
||||
function create_in_destination_fork_and_close() {
|
||||
|
@ -353,8 +367,10 @@ function create_in_destination_fork_and_close() {
|
|||
|
||||
wait_success ${options[url]}/api/v1/repos/user1/origin-fork-destination $(cat $TMPDIR/user1-origin-fork-destination.sha)
|
||||
has_cascade_pull_request
|
||||
test 2 = "$(branches_count user3 destinationrepo)"
|
||||
close_pull_request origin-fork-destination
|
||||
wait_success ${options[url]}/api/v1/repos/user1/origin-fork-destination $(cat $TMPDIR/user1-origin-fork-destination.sha)
|
||||
test 1 = "$(branches_count user3 destinationrepo)"
|
||||
}
|
||||
|
||||
function create_in_existing_destination_fork_and_close() {
|
||||
|
@ -367,8 +383,10 @@ function create_in_existing_destination_fork_and_close() {
|
|||
|
||||
wait_success ${options[url]}/api/v1/repos/user1/origin-organization-fork-destination $(cat $TMPDIR/user1-origin-organization-fork-destination.sha)
|
||||
has_cascade_pull_request
|
||||
test 2 = "$(branches_count destination-fork destinationrepo)"
|
||||
close_pull_request origin-organization-fork-destination
|
||||
wait_success ${options[url]}/api/v1/repos/user1/origin-organization-fork-destination $(cat $TMPDIR/user1-origin-organization-fork-destination.sha)
|
||||
test 1 = "$(branches_count destination-fork destinationrepo)"
|
||||
}
|
||||
|
||||
function create_in_organization_destination_fork_and_close() {
|
||||
|
@ -379,8 +397,10 @@ function create_in_organization_destination_fork_and_close() {
|
|||
|
||||
wait_success ${options[url]}/api/v1/repos/user1/origin-organization-fork-destination $(cat $TMPDIR/user1-origin-organization-fork-destination.sha)
|
||||
has_cascade_pull_request
|
||||
test 2 = "$(branches_count destination-fork destinationrepo)"
|
||||
close_pull_request origin-organization-fork-destination
|
||||
wait_success ${options[url]}/api/v1/repos/user1/origin-organization-fork-destination $(cat $TMPDIR/user1-origin-organization-fork-destination.sha)
|
||||
test 1 = "$(branches_count destination-fork destinationrepo)"
|
||||
}
|
||||
|
||||
function create_and_merge_close() {
|
||||
|
@ -391,9 +411,11 @@ function create_and_merge_close() {
|
|||
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo-close-merge $(cat $TMPDIR/user1-originrepo-close-merge.sha)
|
||||
has_cascade_pull_request
|
||||
test 2 = "$(branches_count user2 destinationrepo)"
|
||||
merge_pull_request originrepo-close-merge
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo-close-merge $(cat $TMPDIR/user1-originrepo-close-merge.sha)
|
||||
has_no_cascade_pull_request
|
||||
test 1 = "$(branches_count user2 destinationrepo)"
|
||||
}
|
||||
|
||||
function run() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue