From 3726ed27c986652b86112e4b6d534d012010ab17 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 20 Jul 2025 07:12:05 +0200 Subject: [PATCH] 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. --- cascading-pr.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cascading-pr.sh b/cascading-pr.sh index 7dd7180..99f3c81 100755 --- a/cascading-pr.sh +++ b/cascading-pr.sh @@ -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() {