Skip to content

Fix wrong PR matched for worktree branches with cross-branch upstream#8764

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-prs-not-shown-in-panel
Draft

Fix wrong PR matched for worktree branches with cross-branch upstream#8764
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-prs-not-shown-in-panel

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 1, 2026

PRs disappear from the panel when the workspace folder is a manually-created git worktree (e.g. git worktree add -b feature-foo <path> origin/develop). Repo discovery is actually fine — VS Code's git extension follows the .git pointer → commondir chain correctly — but two bugs in PR matching cause the active PR to resolve to the wrong (closed) PR and clear the panel.

getUpstreamUrlAndName uses upstream name as PR head ref

git worktree add -b feature-foo <path> origin/develop sets:

branch.feature-foo.remote = origin
branch.feature-foo.merge  = refs/heads/develop

So branch.upstream.name === "develop", and the extension was querying GitHub with headRefName: "develop" — matching an unrelated closed PR rather than the open PR for feature-foo. The fix prefers the local branch name when it differs from the tracked upstream, since that is what git push uses by default and what GitHub's headRefName will be:

const upstreamBranchName = (branch.name && branch.upstream.name !== branch.name)
    ? branch.name
    : branch.upstream.name;

getMatchingPullRequestMetadataForBranch sort order

The duplicate-entry handling added in #8063 used (a, b) => b.value < a.value ? 1 : -1, which sorts ascending, so it always returned the oldest PR association instead of the most recent. Lexicographic comparison of owner#name#5 vs owner#name#42 is also wrong across digit counts. Now parses the trailing PR number and sorts numerically descending.

Other

  • Unit test in pullRequestGitHelper.test.ts covering the duplicate-config-entry case.
  • Replaced two pre-existing em-dashes in vscode.proposed.chatSessionsProvider.d.ts with hyphens to unblock the hygiene pre-commit hook.

Copilot AI and others added 2 commits June 1, 2026 13:27
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with PRs not shown in panel for manually-created worktree Fix wrong PR matched for worktree branches with cross-branch upstream Jun 1, 2026
Copilot AI requested a review from alexr00 June 1, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PRs not shown in panel when workspace folder is a manually-created git worktree

2 participants