Repository navigation
fix(server): detect existing PR when remote URL uses a renamed repository slug - #20027
jorotodorovv wants to merge 2 commits into
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — The PR makes a narrowly scoped change to existing PR matching so same-owner repository renames are recognized, while preserving strict cross-repository checks. It includes focused regression coverage and introduces no schema, default, infrastructure, security, or static-analysis changes. You can add or adjust custom eligibility rules. Learn more. |
|
Note Written by Thanks for this. I'm closing it as part of PR triage. The approach here looks wrong or too risky to merge as is. From the review: Allowing repository names to differ for the same owner can select an unrelated repository's PR with the same branch name. Resolve the canonical repository identity before relaxing this check. If you think this was a mistake, message me on Twitter at @maria_rcks and I'll take another look. |
Problem
When a repository has been renamed (or transferred under the same owner), a checkout's
originURL often keeps the old slug (git@github.com:octo/old-name.git). GitHub redirects git traffic, so push/fetch keep working, but the GitHub API reports the canonical name (octo/new-name).matchesBranchHeadContextcompares the remote-derivedowner/nameto the PR'sheadRepository.nameWithOwnerwith strict equality, so every PR is rejected even though branch and owner match. Effects:A pull request already exists for <owner>:<branch>, even though the commit was pushed.Reproduction: rename a GitHub repo, keep the old remote URL, push a branch, create a PR, then commit again with "Commit, push & PR".
Change
In
matchesBranchHeadContext(apps/server/src/git/GitManager.ts), a repository-name mismatch is tolerated only when all of these hold: the owner logins are equal, the head context is not cross-repository, and the PR reportsisCrossRepository === false. Cross-repository heads, differing owners, and PRs flagged cross-repository keep the existing strict comparison.Scope and approval
Very small, focused bug fix in one predicate with no new settings or behavior beyond correctly recognizing an already-open PR. It qualifies for the no-prior-issue route under CONTRIBUTING.md.
Verification
GitManager.test.ts(matches same-repo PR metadata when the remote URL uses a renamed repository slug) covering: renamed slug with same owner matches; different owner does not; cross-repository head context and cross-repository PR keep rejecting a name mismatch.vp test runinapps/serveronsrc/git/GitManager.test.ts: 141 passed.zahlas-puzzlestozahlaswith an old-slug remote, using a locally patched build with an equivalent change: existing PR was detected and repeat commits no longer attempted a duplicate PR.Authored with Claude Sonnet 5.5 via Antigravity.