fix(github): stop fork remotes from claiming the local branch's PR badge

PR-status source candidates were every configured remote, so a checkout
carrying contributor forks matched a fork's closed PR whose head merely
shared the branch name — a fork's 'main' surfaced on the local main in the
git and work-status panels. Only the ranked-first remote (the one the
branch pushes to) and its fork network are PR sources now; other remotes
remain search targets but their owner:branch heads no longer count.
This commit is contained in:
Bohdan Triapitsyn
2026-08-26 18:40:34 +03:00
parent 098034dc33
commit edec60faff
2 changed files with 11 additions and 1 deletions
+10 -1
View File
@@ -674,7 +674,16 @@ export async function resolveGitHubPrStatus({ octokit, directory, branch, remote
};
}
const sourceCandidates = resolvedTargets.slice();
// Only the repo this branch actually pushes to (the ranked-first remote)
// and its fork network can be the SOURCE of the branch's PRs. Other
// configured remotes — a maintainer's checkout often carries contributor
// forks — are places to look for an open PR, but their `owner:branch`
// heads are unrelated branches that merely share a name; treating them as
// sources made a fork's closed `main` PR show up on the local main.
const primaryRemoteName = resolvedTargets[0]?.remoteName ?? null;
const sourceCandidates = resolvedTargets.filter(
(target) => target.remoteName === primaryRemoteName,
);
// When every consulted repo list was complete, a no-PR result is
// authoritative and the expensive Search API fallback is pointless.
const coverage = { authoritative: true };