Fix SCM repository resolution and add branch name support#302321
Open
wolfsilver wants to merge 4 commits intomicrosoft:mainfrom
Open
Fix SCM repository resolution and add branch name support#302321wolfsilver wants to merge 4 commits intomicrosoft:mainfrom
wolfsilver wants to merge 4 commits intomicrosoft:mainfrom
Conversation
This fixes the issue where _scmService.getRepository() returns undefined when called with a URI that points exactly to the repository root directory.
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @lszomoruMatched files:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new ${branch} terminal tab label/description variable by plumbing the current Git branch name from the Git extension through the SCM provider layer into the terminal label computation, alongside a small fix to SCM repository resolution.
Changes:
- Expose an SCM provider
branchName(observable) end-to-end: extension hostSourceControl.branchName→ ext host protocol DTO → main thread SCM provider. - Add
${branch}support in terminal tab label computation and update terminal label docs plus a unit test. - Fix SCM repository resolution to correctly match when the resource URI is exactly the repository root.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.d.ts | Adds SourceControl.branchName?: string to the public API surface. |
| src/vs/workbench/contrib/terminal/test/browser/terminalInstance.test.ts | Adds a unit test validating ${branch} resolves in terminal labels. |
| src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts | Documents the new ${branch} variable in terminal tab label settings. |
| src/vs/workbench/contrib/terminal/browser/terminalInstance.ts | Wires ${branch} into label templating and adds branch-change-driven label refresh logic. |
| src/vs/workbench/contrib/scm/common/scmService.ts | Fixes repository matching for resources at the repo root. |
| src/vs/workbench/contrib/scm/common/scm.ts | Adds `branchName: IObservable<string |
| src/vs/workbench/api/common/extHostSCM.ts | Adds branchName property on ExtHostSourceControl and forwards updates to main thread. |
| src/vs/workbench/api/common/extHost.protocol.ts | Adds branchName?: string to SCMProviderFeatures DTO. |
| src/vs/workbench/api/browser/mainThreadSCM.ts | Stores branch name as an observable on the main-thread SCM provider and updates it via $updateSourceControl. |
| extensions/git/src/repository.ts | Updates SourceControl.branchName based on the repository HEAD on status refresh. |
You can also share your feedback on Copilot code review. Take the survey.
| this._setTitle(this.title, TitleEventSource.Config); | ||
| // Subscribe to branch name changes for the new cwd | ||
| this._subscribeToBranchNameChanges(e); | ||
| })); |
| } | ||
|
|
||
| try { | ||
| const cwdUri = URI.file(cwd); |
| } | ||
|
|
||
| try { | ||
| const cwdUri = URI.file(cwd); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
This pull request adds support for displaying the current Git branch name in the integrated terminal's tab labels and descriptions. It achieves this by exposing the branch name from the Git extension through the SCM provider, making it observable, and wiring it into the terminal label computation and updates. The changes also include tests and documentation for the new
${branch}variable.These changes allow the terminal UI to dynamically display the current Git branch, improving user awareness and workflow integration.
Fixes #237004