mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-07-21 23:08:23 +02:00
fix: loop over the open pull requests to get an exact title match
The q= argument of the search may not return matches that are exactly the title depending on how the issue search is defined. https://code.forgejo.org/forgejo/end-to-end/actions/runs/3505/jobs/4 is an example of a failed run because q= did not match the right pull request.
This commit is contained in:
parent
80ba22a9a4
commit
3726ed27c9
1 changed files with 13 additions and 1 deletions
|
@ -132,7 +132,19 @@ function pr_get_origin() {
|
|||
|
||||
function pr_get_destination() {
|
||||
local title=$(pr_destination_title)
|
||||
repo_curl ${options[destination_repo]} api --get --data state=open --data type=pulls --data-urlencode q="$title" ${options[destination_api]}/issues | jq --raw-output .[0] >$TMPDIR/destination-pr.json
|
||||
local page=1
|
||||
touch $TMPDIR/destination-pr.json
|
||||
while true; do
|
||||
repo_curl ${options[destination_repo]} api --get --data page=$page --data state=open --data type=pulls ${options[destination_api]}/issues >$TMPDIR/destination-prs.json
|
||||
if test "$(jq length <$TMPDIR/destination-prs.json)" = 0; then
|
||||
break
|
||||
fi
|
||||
jq --argjson title "\"$title\"" '.[] | select(.title == $title)' <$TMPDIR/destination-prs.json >$TMPDIR/destination-pr.json
|
||||
if test -s $TMPDIR/destination-pr.json; then
|
||||
break
|
||||
fi
|
||||
page=$(expr $page + 1)
|
||||
done
|
||||
}
|
||||
|
||||
function pr_get() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue