Fix wrong PR matched for worktree branches with cross-branch upstream#8764
Draft
Copilot wants to merge 3 commits into
Draft
Fix wrong PR matched for worktree branches with cross-branch upstream#8764Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.gitpointer →commondirchain correctly — but two bugs in PR matching cause the active PR to resolve to the wrong (closed) PR and clear the panel.getUpstreamUrlAndNameuses upstream name as PR head refgit worktree add -b feature-foo <path> origin/developsets:So
branch.upstream.name === "develop", and the extension was querying GitHub withheadRefName: "develop"— matching an unrelated closed PR rather than the open PR forfeature-foo. The fix prefers the local branch name when it differs from the tracked upstream, since that is whatgit pushuses by default and what GitHub'sheadRefNamewill be:getMatchingPullRequestMetadataForBranchsort orderThe 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 ofowner#name#5vsowner#name#42is also wrong across digit counts. Now parses the trailing PR number and sorts numerically descending.Other
pullRequestGitHelper.test.tscovering the duplicate-config-entry case.vscode.proposed.chatSessionsProvider.d.tswith hyphens to unblock thehygienepre-commit hook.