fix: resolve SCM repository lookup failures on Windows SUBST drives#5185
Open
TheBroken0ne wants to merge 4 commits into
Open
fix: resolve SCM repository lookup failures on Windows SUBST drives#5185TheBroken0ne wants to merge 4 commits into
TheBroken0ne wants to merge 4 commits into
Conversation
On Windows, `fs.realpath` does not resolve SUBST drive substitutions, but `git rev-parse --show-toplevel` does. This causes a permanent path mismatch between GitLens's canonical repo paths and VS Code SCM's SUBST-based paths, making SCM-dependent features (Generate Commit Message, etc.) silently fail. Detect SUBST drives in `findRepositoryUri` by comparing drive letters between the workspace URI and the git-reported repo path, then resolve the SUBST target via `realpath.native` on the drive root to populate `toCanonicalMap`/`fromCanonicalMap`. Use these mappings in `getScmRepository` and `getOrOpenScmRepository` to fall back to the SUBST path when the canonical path doesn't match any SCM repository.
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.
Problem
On Windows, when a workspace is opened via a SUBST drive (e.g.,
D:is a substitute forC:\LOCAL), SCM-dependent features like Generate Commit Message silently fail. The SCM input box button does nothing — no error, no notification.Root Cause
fs.realpath()does not resolve Windows SUBST drive substitutions, butgit rev-parse --show-topleveldoes. This creates a permanent path mismatch:c:/LOCAL/Applfich/Sicar/SicarSuited:/Applfich/Sicar/SicarSuiteIn
findRepositoryUri(), the symlink detection code comparesrealpath(uri.fsPath)withuri.fsPath. Sincerealpathreturns the SUBST path unchanged, no symlink is detected, andtoCanonicalMap/fromCanonicalMapare never populated. Downstream,getScmRepository()andgetOrOpenScmRepository()look up the canonical path in VS Code's SCM API, which only knows the SUBST path — the lookup fails, and the command silently returns.Fix
Three targeted changes in
cliGitProvider.ts:findRepositoryUri(): After the existingfs.realpathsymlink detection, added a Windows-specificelse ifthat detects SUBST drives by comparing drive letters between the workspace URI and the git-reported repo path. Usesrealpath.native()on the drive root to resolve the SUBST target and populatestoCanonicalMap/fromCanonicalMap.getScmRepository(): Falls back totoCanonicalMapwhen the canonical path doesn't match any SCM repository.getOrOpenScmRepository(): Resolves the effective URI viatoCanonicalMapbefore querying/opening the SCM repository.Testing
Tested on Windows 11 with:
D:→C:\LOCAL)