mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-06-28 04:43:44 +00:00
add a test for forked destination
This commit is contained in:
parent
dd5427bc63
commit
a98dc1dffc
6 changed files with 91 additions and 24 deletions
|
@ -170,7 +170,7 @@ function git_clone() {
|
|||
}
|
||||
|
||||
function git_checkout() {
|
||||
local direction=$1 ref="$3"
|
||||
local direction=$1 ref="$2"
|
||||
local remote=origin
|
||||
|
||||
(
|
||||
|
@ -245,12 +245,12 @@ function upsert_fork() {
|
|||
return 1
|
||||
fi
|
||||
else
|
||||
local fork_owner=$(owner ${options[destination_fork]})
|
||||
local fork_owner=$(owner ${options[destination_fork_repo]})
|
||||
local data="{}"
|
||||
if repo_curl ${options[destination_repo]} api_json ${options[destination_url]}/api/v1/orgs/${fork_owner} >& /dev/null ; then
|
||||
data='{"organization":"'$fork_owner'"}'
|
||||
fi
|
||||
repo_curl ${options[destination_repo]} api_json --data "$data" ${options[destination_url]}/api/v1/${options[destination_repo]}/forks
|
||||
repo_curl ${options[destination_repo]} api_json --data "$data" ${options[destination_url]}/api/v1/repos/${options[destination_repo]}/forks
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -304,8 +304,8 @@ function update() {
|
|||
push destination $remote_head ${options[destination_head]}
|
||||
}
|
||||
|
||||
function set_clone() {
|
||||
local direction=$1
|
||||
function set_git_url() {
|
||||
local direction=$1 name=$2 repo=$3
|
||||
local token=${options[${direction}_token]}
|
||||
|
||||
if [[ "$token" =~ ^@ ]] ; then
|
||||
|
@ -313,12 +313,12 @@ function set_clone() {
|
|||
(
|
||||
echo -n ${options[${direction}_scheme]}://any:
|
||||
cat $file
|
||||
echo @${options[${direction}_host_port]}/${options[${direction}_repo]}
|
||||
echo @${options[${direction}_host_port]}/$repo
|
||||
) > $TMPDIR/$direction.git-credentials
|
||||
else
|
||||
echo ${options[${direction}_scheme]}://any:${options[${direction}_token]}@${options[${direction}_host_port]}/${options[${direction}_repo]} > $TMPDIR/$direction.git-credentials
|
||||
echo ${options[${direction}_scheme]}://any:${options[${direction}_token]}@${options[${direction}_host_port]}/$repo > $TMPDIR/$direction.git-credentials
|
||||
fi
|
||||
options[${direction}_clone]=${options[${direction}_scheme]}://${options[${direction}_host_port]}/${options[${direction}_repo]}
|
||||
options[$name]=${options[${direction}_scheme]}://${options[${direction}_host_port]}/$repo
|
||||
}
|
||||
|
||||
function fork_sanity_check() {
|
||||
|
@ -334,13 +334,13 @@ function finalize_options() {
|
|||
options[origin_api]=${options[origin_url]}/api/v1/repos/${options[origin_repo]}
|
||||
options[origin_scheme]=$(scheme ${options[origin_url]})
|
||||
options[origin_host_port]=$(host_port ${options[origin_url]})
|
||||
set_clone origin
|
||||
set_git_url origin origin_clone ${options[origin_repo]}
|
||||
options[origin_head]=refs/pull/${options[origin_pr]}/head
|
||||
|
||||
options[destination_api]=${options[destination_url]}/api/v1/repos/${options[destination_repo]}
|
||||
options[destination_scheme]=$(scheme ${options[destination_url]})
|
||||
options[destination_host_port]=$(host_port ${options[destination_url]})
|
||||
set_clone destination
|
||||
set_git_url destination destination_clone ${options[destination_repo]}
|
||||
options[destination_base]=${options[destination_branch]}
|
||||
: ${options[prefix]:=${options[origin_repo]}}
|
||||
options[destination_head]=${options[prefix]}-${options[origin_pr]}
|
||||
|
@ -348,7 +348,9 @@ function finalize_options() {
|
|||
if test "${options[destination_fork_repo]}"; then
|
||||
fork_sanity_check
|
||||
options[destination_is_fork]=true
|
||||
set_git_url destination destination_fetch_fork ${options[destination_fork_repo]}
|
||||
options[destination_fork_api]=${options[destination_url]}/api/v1/repos/${options[destination_fork_repo]}
|
||||
else
|
||||
options[destination_is_fork]=false
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue