close-merge input

Fixes: https://code.forgejo.org/actions/cascading-pr/issues/7
This commit is contained in:
Earl Warren 2023-10-24 22:51:30 +02:00
parent f8a65b3d9f
commit 5caaedbc52
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
7 changed files with 80 additions and 9 deletions

View file

@ -241,6 +241,7 @@ function finalize_options() {
options[destination_base]=${options[destination_branch]}
: ${options[prefix]:=${options[origin_repo]}}
options[destination_head]=${options[prefix]}-${options[origin_pr]}
: ${options[close_merge]:=false}
}
function run() {
@ -262,11 +263,17 @@ function run() {
;;
closed)
if "$(pr_merged origin)"; then
log_info "PR was merged, update the cascade PR"
repo_login ${options[destination_repo]}
pr_get origin
pr_get destination
update
if "${options[close_merge]}" ; then
log_info "PR is merged, close the cascade PR and remove the branch"
repo_login ${options[destination_repo]}
close_pr
else
log_info "PR was merged, update the cascade PR"
repo_login ${options[destination_repo]}
pr_get origin
pr_get destination
update
fi
else
log_info "PR is closed, close the cascade PR and remove the branch"
repo_login ${options[destination_repo]}
@ -340,6 +347,11 @@ function main() {
options[prefix]=$1
shift
;;
--close-merge)
shift
options[close_merge]=$1
shift
;;
*)
finalize_options
"${1:-run}"