Sfoglia il codice sorgente

Adds better handling of repo at UNC root

main
Eric Amodio 1 anno fa
parent
commit
da901c2b43
3 ha cambiato i file con 16 aggiunte e 5 eliminazioni
  1. +6
    -1
      src/env/node/git/localGitProvider.ts
  2. +8
    -0
      src/system/path.ts
  3. +2
    -4
      src/trackers/documentTracker.ts

+ 6
- 1
src/env/node/git/localGitProvider.ts Vedi File

@ -170,6 +170,7 @@ import {
joinPaths,
maybeUri,
normalizePath,
pathEquals,
relative,
splitPath,
} from '../../../system/path';
@ -1364,10 +1365,14 @@ export class LocalGitProvider implements GitProvider, Disposable {
),
);
if (networkPath != null) {
// If the repository is at the root of the mapped drive then we
// have to append `\` (ex: D:\) otherwise the path is not valid.
const isDriveRoot = pathEquals(repoUri.fsPath, networkPath);
repoPath = normalizePath(
repoUri.fsPath.replace(
networkPath,
`${letter.toLowerCase()}:${networkPath.endsWith('\\') ? '\\' : ''}`,
`${letter.toLowerCase()}:${isDriveRoot || networkPath.endsWith('\\') ? '\\' : ''}`,
),
);
return Uri.file(repoPath);

+ 8
- 0
src/system/path.ts Vedi File

@ -191,6 +191,14 @@ export function normalizePath(path: string): string {
return path;
}
export function pathEquals(a: string, b: string, ignoreCase?: boolean): boolean {
if (ignoreCase || (ignoreCase == null && !isLinux)) {
a = a.toLowerCase();
b = b.toLowerCase();
}
return normalizePath(a) === normalizePath(b);
}
export function relative(from: string, to: string, ignoreCase?: boolean): string {
from = hasSchemeRegex.test(from) ? Uri.parse(from, true).path : normalizePath(from);
to = hasSchemeRegex.test(to) ? Uri.parse(to, true).path : normalizePath(to);

+ 2
- 4
src/trackers/documentTracker.ts Vedi File

@ -150,11 +150,9 @@ export class DocumentTracker implements Disposable {
private onRepositoriesChanged(e: RepositoriesChangeEvent) {
void this.refreshDocuments({
addedOrChangedRepoPaths: e.added.length
? new Set<string>(e.added.map(r => r.path.toLocaleLowerCase()))
: undefined,
removedRepoPaths: e.removed.length
? new Set<string>(e.removed.map(r => r.path.toLocaleLowerCase()))
? new Set<string>(e.added.map(r => r.path.toLowerCase()))
: undefined,
removedRepoPaths: e.removed.length ? new Set<string>(e.removed.map(r => r.path.toLowerCase())) : undefined,
});
}

Caricamento…
Annulla
Salva