Procházet zdrojové kódy

Fixes #1882 symlinks on windows not working

main
Eric Amodio před 2 roky
rodič
revize
bc5df01609
2 změnil soubory, kde provedl 35 přidání a 28 odebrání
  1. +1
    -0
      CHANGELOG.md
  2. +34
    -28
      src/env/node/git/localGitProvider.ts

+ 1
- 0
CHANGELOG.md Zobrazit soubor

@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## Fixed
- Fixes [#1882](https://github.com/gitkraken/vscode-gitlens/issues/1882) - Blame annotations not showing anymore after update
- Fixes [#1787](https://github.com/gitkraken/vscode-gitlens/issues/1787) - Remove '-review' from Gerrit Remote reviewDomain() — thanks to [PR #1954](https://github.com/gitkraken/vscode-gitlens/pull/1954) by Felipe Santos ([@felipecrs](https://github.com/felipecrs))
- Fixes [#1902](https://github.com/gitkraken/vscode-gitlens/issues/1902) - Support replacing mirror/replica domain with main domain for remote provider — thanks to [PR #1954](https://github.com/gitkraken/vscode-gitlens/pull/1954) by Felipe Santos ([@felipecrs](https://github.com/felipecrs))

+ 34
- 28
src/env/node/git/localGitProvider.ts Zobrazit soubor

@ -913,51 +913,57 @@ export class LocalGitProvider implements GitProvider, Disposable {
let repoPath: string | undefined;
try {
let isSymLink = undefined;
if (!isDirectory) {
const stats = await workspace.fs.stat(uri);
uri = stats?.type === FileType.Directory ? uri : Uri.file(dirname(uri.fsPath));
isSymLink = ((stats?.type ?? 0) & FileType.SymbolicLink) === FileType.SymbolicLink;
}
repoPath = await this.git.rev_parse__show_toplevel(uri.fsPath);
if (!repoPath) return undefined;
if (isWindows) {
// On Git 2.25+ if you call `rev-parse --show-toplevel` on a mapped drive, instead of getting the mapped drive path back, you get the UNC path for the mapped drive.
// So try to normalize it back to the mapped drive path, if possible
const repoUri = Uri.file(repoPath);
const repoUri = Uri.file(repoPath);
if (repoUri.authority.length !== 0 && uri.authority.length === 0) {
const match = driveLetterRegex.exec(uri.path);
if (match != null) {
const [, letter] = match;
// On Git 2.25+ if you call `rev-parse --show-toplevel` on a mapped drive, instead of getting the mapped drive path back, you get the UNC path for the mapped drive.
// So try to normalize it back to the mapped drive path, if possible
if (isWindows && repoUri.authority.length !== 0 && uri.authority.length === 0) {
const match = driveLetterRegex.exec(uri.path);
if (match != null) {
const [, letter] = match;
try {
const networkPath = await new Promise<string | undefined>(resolve =>
realpath.native(`${letter}:\\`, { encoding: 'utf8' }, (err, resolvedPath) =>
resolve(err != null ? undefined : resolvedPath),
try {
const networkPath = await new Promise<string | undefined>(resolve =>
realpath.native(`${letter}:\\`, { encoding: 'utf8' }, (err, resolvedPath) =>
resolve(err != null ? undefined : resolvedPath),
),
);
if (networkPath != null) {
repoPath = normalizePath(
repoUri.fsPath.replace(
networkPath,
`${letter.toLowerCase()}:${networkPath.endsWith('\\') ? '\\' : ''}`,
),
);
if (networkPath != null) {
repoPath = normalizePath(
repoUri.fsPath.replace(
networkPath,
`${letter.toLowerCase()}:${networkPath.endsWith('\\') ? '\\' : ''}`,
),
);
return Uri.file(repoPath);
}
} catch {}
}
return Uri.file(normalizePath(uri.fsPath));
return Uri.file(repoPath);
}
} catch {}
}
return repoUri;
return Uri.file(normalizePath(uri.fsPath));
}
// If we are not on Windows (symlinks don't seem to have the same issue on Windows), check if we are a symlink and if so, use the symlink path (not its resolved path)
// Check if we are a symlink and if so, use the symlink path (not its resolved path)
// This is because VS Code will provide document Uris using the symlinked path
if (isSymLink == null) {
const stats = await workspace.fs.stat(uri);
isSymLink = ((stats?.type ?? 0) & FileType.SymbolicLink) === FileType.SymbolicLink;
}
if (!isSymLink) return repoUri;
repoPath = await new Promise<string | undefined>(resolve => {
realpath(uri.fsPath, { encoding: 'utf8' }, (err, resolvedPath) => {
if (err != null) {

Načítá se…
Zrušit
Uložit