Fix forge pr find-by-head / branch resolution returning the wrong PR #106
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools!106
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/fix-forge-find-by-head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fix
forge pr find-by-head(and the shared branch→PR resolver) returning the wrong PR.The Gitea/Forgejo pulls-list endpoint does not support a
headquery filter, soGET /repos/{repo}/pulls?state=open&head=<branch>silently ignored the filter and returned every open PR. Bothpr_find_by_headandresolve_pr_targetthen took the first element, so they resolved any branch name to whichever open PR happened to sort first. With two or more open PRs in a repo this returns the wrong PR —forge pr find-by-head <branch>returns an unrelated PR,forge pr close <branch>/pr view <branch>could target the wrong PR, andallod change submitrefuses to open a second concurrent PR in a repo (false "PR already exists").Fix: drop the ignored
head=query param and match.head.refclient-side in jq.The test mock had faked server-side
head=filtering (returning a hand-picked PR per head), which hid the bug. The mock now mirrors the real API — the open-PR list ignores head and returns all PRs — and its fixtures carry two PRs with distinct head refs. New regression cases assertfind-by-headmatches the correct (non-first) PR by head and returns nothing for an unmatched branch.Risk
The
forgechange is limited to the two list-and-match spots;urlencodeis unchanged and still used for other query params (milestone/label/search/branch-delete). Numeric and URL PR targets are untouched.Validation
Full forge test suite passes (read, pr-close, mutations, validation, help, auth, token, issue-close). Verified against the live forge: the fixed
forge pr find-by-headreturns the PR whose head actually matches (and empty for an unknown branch), whereas the installed build returns whichever PR lists first regardless of the branch argument.