mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-06-27 20:33:44 +00:00
run the update script from the default branch
Fixes: https://code.forgejo.org/actions/cascading-pr/issues/9
This commit is contained in:
parent
39c71c3f40
commit
277569106a
6 changed files with 87 additions and 23 deletions
|
@ -4,9 +4,11 @@ set -ex
|
|||
|
||||
destination_checkout="$1"
|
||||
destination_pr_json="$2"
|
||||
origin_pr_json="$3"
|
||||
origin_checkout="$3"
|
||||
origin_pr_json="$4"
|
||||
|
||||
test -d $destination_checkout
|
||||
test -d $origin_checkout
|
||||
test -f $origin_pr_json
|
||||
|
||||
date +%s > $destination_checkout/last
|
||||
|
|
|
@ -4,9 +4,11 @@ set -ex
|
|||
|
||||
destination_checkout="$1"
|
||||
destination_pr_json="$2"
|
||||
origin_pr_json="$3"
|
||||
origin_checkout="$3"
|
||||
origin_pr_json="$4"
|
||||
|
||||
test -d $destination_checkout
|
||||
test -d $origin_checkout
|
||||
test -f $origin_pr_json
|
||||
|
||||
date +%s > $destination_checkout/last
|
||||
|
|
45
tests/run.sh
45
tests/run.sh
|
@ -77,7 +77,7 @@ function has_cascade_pull_request() {
|
|||
}
|
||||
|
||||
function create_branch1() {
|
||||
local owner=$1 repo=$2
|
||||
local owner=$1 repo=$2 modify=$3
|
||||
|
||||
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/repos/$owner/${repo}/branches/branch1 >& /dev/null || true
|
||||
forgejo-curl.sh api_json --data '{"new_branch_name":"branch1"}' ${options[url]}/api/v1/repos/$owner/${repo}/branches
|
||||
|
@ -87,6 +87,7 @@ function create_branch1() {
|
|||
git clone -b branch1 http://user1:admin1234@${options[host_port]}/$owner/${repo}
|
||||
cd ${repo}
|
||||
echo CONTENT > README
|
||||
$modify
|
||||
git config user.email root@example.com
|
||||
git config user.name username
|
||||
git add .
|
||||
|
@ -96,15 +97,18 @@ function create_branch1() {
|
|||
)
|
||||
}
|
||||
|
||||
function delete_pull_requests() {
|
||||
local owner=$1 repo=$2
|
||||
|
||||
forgejo-curl.sh api_json ${options[url]}/api/v1/repos/$owner/${repo}/pulls | jq --raw-output '.[] | .number' | while read pr ; do
|
||||
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/repos/$owner/${repo}/issues/$pr
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function create_pull_request() {
|
||||
local baseowner=$1 headowner=$2 repo=$3
|
||||
|
||||
forgejo-curl.sh api_json ${options[url]}/api/v1/repos/$baseowner/${repo}/pulls | jq --raw-output '.[] | .number' | while read pr ; do
|
||||
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/repos/$baseowner/${repo}/issues/$pr
|
||||
done
|
||||
|
||||
create_branch1 $headowner $repo
|
||||
|
||||
local head
|
||||
if test $baseowner == $headowner; then
|
||||
head=branch1
|
||||
|
@ -117,6 +121,14 @@ EOF
|
|||
forgejo-curl.sh api_json --data @$TMPDIR/data ${options[url]}/api/v1/repos/$baseowner/${repo}/pulls
|
||||
}
|
||||
|
||||
function create_pull_request_case1() {
|
||||
local baseowner=$1 headowner=$2 repo=$3
|
||||
|
||||
delete_pull_requests $baseowner $repo
|
||||
create_branch1 $headowner $repo
|
||||
create_pull_request $baseowner $headowner $repo
|
||||
}
|
||||
|
||||
function finalize_options() {
|
||||
if test -f forgejo-ip; then
|
||||
: ${options[host_port]:=$(cat forgejo-ip):3000}
|
||||
|
@ -198,7 +210,7 @@ function fixture() {
|
|||
function no_change_no_cascade_pr() {
|
||||
fixture originrepo-do-nothing destinationrepo
|
||||
|
||||
create_pull_request user1 user1 originrepo-do-nothing
|
||||
create_pull_request_case1 user1 user1 originrepo-do-nothing
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo-do-nothing $(cat $TMPDIR/user1-originrepo-do-nothing.sha)
|
||||
! has_cascade_pull_request
|
||||
}
|
||||
|
@ -206,17 +218,28 @@ function no_change_no_cascade_pr() {
|
|||
function create_and_close() {
|
||||
fixture originrepo destinationrepo
|
||||
|
||||
create_pull_request user1 user1 originrepo
|
||||
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
|
||||
close_pull_request
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo $(cat $TMPDIR/user1-originrepo.sha)
|
||||
}
|
||||
|
||||
function taint_update() {
|
||||
if ! test -f upgraded ; then
|
||||
echo upgraded file not found
|
||||
return 1
|
||||
fi
|
||||
echo 'TAINTED' > upgraded
|
||||
}
|
||||
|
||||
function create_from_fork_and_close() {
|
||||
fixture originrepo destinationrepo
|
||||
|
||||
delete_pull_requests user1 originrepo
|
||||
create_branch1 fork-org originrepo taint_update
|
||||
create_pull_request user1 fork-org originrepo
|
||||
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo $(cat $TMPDIR/fork-org-originrepo.sha)
|
||||
has_cascade_pull_request
|
||||
close_pull_request
|
||||
|
@ -226,7 +249,7 @@ function create_from_fork_and_close() {
|
|||
function create_and_merge() {
|
||||
fixture originrepo destinationrepo
|
||||
|
||||
create_pull_request user1 user1 originrepo
|
||||
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
|
||||
merge_pull_request originrepo
|
||||
|
@ -237,7 +260,7 @@ function create_and_merge() {
|
|||
function create_and_merge_close() {
|
||||
fixture originrepo-close-merge destinationrepo
|
||||
|
||||
create_pull_request user1 user1 originrepo-close-merge
|
||||
create_pull_request_case1 user1 user1 originrepo-close-merge
|
||||
wait_success ${options[url]}/api/v1/repos/user1/originrepo-close-merge $(cat $TMPDIR/user1-originrepo-close-merge.sha)
|
||||
has_cascade_pull_request
|
||||
merge_pull_request originrepo-close-merge
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue