Selaa lähdekoodia

Adds better handling of repo at UNC root

main
Eric Amodio 1 vuosi sitten
vanhempi
commit
da901c2b43
3 muutettua tiedostoa jossa 16 lisäystä ja 5 poistoa
  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 Näytä tiedosto

@ -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 Näytä tiedosto

@ -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 Näytä tiedosto

@ -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,
});
}

Ladataan…
Peruuta
Tallenna