Переглянути джерело

Renames GitUri resolve/resolveToUri

main
Eric Amodio 2 роки тому
джерело
коміт
817360ca6c
9 змінених файлів з 34 додано та 40 видалено
  1. +1
    -1
      src/commands/diffWithRevisionFrom.ts
  2. +3
    -3
      src/env/node/git/localGitProvider.ts
  3. +20
    -26
      src/git/gitUri.ts
  4. +3
    -3
      src/git/models/commit.ts
  5. +1
    -1
      src/git/models/logCommit.ts
  6. +1
    -1
      src/git/models/status.ts
  7. +2
    -2
      src/views/nodes/mergeConflictFileNode.ts
  8. +2
    -2
      src/views/nodes/statusFileNode.ts
  9. +1
    -1
      src/vsls/host.ts

+ 1
- 1
src/commands/diffWithRevisionFrom.ts Переглянути файл

@ -86,7 +86,7 @@ export class DiffWithRevisionFromCommand extends ActiveEditorCommand {
const fileName = normalizePath(relative(gitUri.repoPath, gitUri.fsPath)); const fileName = normalizePath(relative(gitUri.repoPath, gitUri.fsPath));
const rename = files.find(s => s.fileName === fileName); const rename = files.find(s => s.fileName === fileName);
if (rename?.originalFileName != null) { if (rename?.originalFileName != null) {
renamedUri = GitUri.resolveToUri(rename.originalFileName, gitUri.repoPath);
renamedUri = GitUri.resolve(rename.originalFileName, gitUri.repoPath);
renamedTitle = `${basename(rename.originalFileName)} (${GitRevision.shorten(ref)})`; renamedTitle = `${basename(rename.originalFileName)} (${GitRevision.shorten(ref)})`;
} }
} }

+ 3
- 3
src/env/node/git/localGitProvider.ts Переглянути файл

@ -2624,7 +2624,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
else { else {
ref = blameLine.commit.sha; ref = blameLine.commit.sha;
fileName = blameLine.commit.fileName || (blameLine.commit.originalFileName ?? fileName); fileName = blameLine.commit.fileName || (blameLine.commit.originalFileName ?? fileName);
uri = GitUri.resolveToUri(fileName, repoPath);
uri = GitUri.resolve(fileName, repoPath);
editorLine = blameLine.line.originalLine - 1; editorLine = blameLine.line.originalLine - 1;
if (skip === 0 && blameLine.commit.previousSha) { if (skip === 0 && blameLine.commit.previousSha) {
@ -2653,7 +2653,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
// Diff with line ref with previous // Diff with line ref with previous
ref = blameLine.commit.sha; ref = blameLine.commit.sha;
fileName = blameLine.commit.fileName || (blameLine.commit.originalFileName ?? fileName); fileName = blameLine.commit.fileName || (blameLine.commit.originalFileName ?? fileName);
uri = GitUri.resolveToUri(fileName, repoPath);
uri = GitUri.resolve(fileName, repoPath);
editorLine = blameLine.line.originalLine - 1; editorLine = blameLine.line.originalLine - 1;
if (skip === 0 && blameLine.commit.previousSha) { if (skip === 0 && blameLine.commit.previousSha) {
@ -3367,7 +3367,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
fileName = foundFile; fileName = foundFile;
} while (true); } while (true);
uri = GitUri.resolveToUri(fileName, repoPath);
uri = GitUri.resolve(fileName, repoPath);
return (await fsExists(uri.fsPath)) ? uri : undefined; return (await fsExists(uri.fsPath)) ? uri : undefined;
} }

+ 20
- 26
src/git/gitUri.ts Переглянути файл

@ -99,10 +99,20 @@ export class GitUri extends (Uri as any as UriEx) {
return; return;
} }
const [authority, fsPath] = GitUri.ensureValidUNCPath(
uri.authority,
GitUri.resolve(commitOrRepoPath.fileName ?? uri.fsPath, commitOrRepoPath.repoPath),
);
let authority = uri.authority;
let fsPath = GitUri.resolvePath(commitOrRepoPath.fileName ?? uri.fsPath, commitOrRepoPath.repoPath);
// Check for authority as used in UNC shares or use the path as given
if (fsPath.charCodeAt(0) === CharCode.Slash && fsPath.charCodeAt(1) === CharCode.Slash) {
const index = fsPath.indexOf('/', 2);
if (index === -1) {
authority = fsPath.substring(2);
fsPath = '/';
} else {
authority = fsPath.substring(2, index);
fsPath = fsPath.substring(index) || '/';
}
}
let path; let path;
switch (uri.scheme) { switch (uri.scheme) {
@ -198,22 +208,6 @@ export class GitUri extends (Uri as any as UriEx) {
return GitUri.file(this.fsPath); return GitUri.file(this.fsPath);
} }
private static ensureValidUNCPath(authority: string, fsPath: string): [string, string] {
// Check for authority as used in UNC shares or use the path as given
if (fsPath.charCodeAt(0) === CharCode.Slash && fsPath.charCodeAt(1) === CharCode.Slash) {
const index = fsPath.indexOf('/', 2);
if (index === -1) {
authority = fsPath.substring(2);
fsPath = '/';
} else {
authority = fsPath.substring(2, index);
fsPath = fsPath.substring(index) || '/';
}
}
return [authority, fsPath];
}
static file(path: string, useVslsScheme?: boolean) { static file(path: string, useVslsScheme?: boolean) {
const uri = Uri.file(path); const uri = Uri.file(path);
if (Container.instance.vsls.isMaybeGuest && useVslsScheme !== false) { if (Container.instance.vsls.isMaybeGuest && useVslsScheme !== false) {
@ -233,7 +227,7 @@ export class GitUri extends (Uri as any as UriEx) {
} }
static fromFile(file: string | GitFile, repoPath: string, ref?: string, original: boolean = false): GitUri { static fromFile(file: string | GitFile, repoPath: string, ref?: string, original: boolean = false): GitUri {
const uri = GitUri.resolveToUri(
const uri = GitUri.resolve(
typeof file === 'string' ? file : (original && file.originalFileName) || file.fileName, typeof file === 'string' ? file : (original && file.originalFileName) || file.fileName,
repoPath, repoPath,
); );
@ -413,7 +407,7 @@ export class GitUri extends (Uri as any as UriEx) {
} }
static git(fileName: string, repoPath?: string) { static git(fileName: string, repoPath?: string) {
const path = GitUri.resolve(fileName, repoPath);
const path = GitUri.resolvePath(fileName, repoPath);
return Uri.parse( return Uri.parse(
// Change encoded / back to / otherwise uri parsing won't work properly // Change encoded / back to / otherwise uri parsing won't work properly
`${DocumentSchemes.Git}:/${encodeURIComponent(path).replace(/%2F/g, '/')}?${encodeURIComponent( `${DocumentSchemes.Git}:/${encodeURIComponent(path).replace(/%2F/g, '/')}?${encodeURIComponent(
@ -426,7 +420,7 @@ export class GitUri extends (Uri as any as UriEx) {
); );
} }
static resolve(fileName: string, repoPath?: string) {
static resolvePath(fileName: string, repoPath?: string) {
const normalizedFileName = normalizePath(fileName); const normalizedFileName = normalizePath(fileName);
if (repoPath === undefined) return normalizedFileName; if (repoPath === undefined) return normalizedFileName;
@ -438,8 +432,8 @@ export class GitUri extends (Uri as any as UriEx) {
return normalizePath(joinPaths(normalizedRepoPath, normalizedFileName)); return normalizePath(joinPaths(normalizedRepoPath, normalizedFileName));
} }
static resolveToUri(fileName: string, repoPath?: string) {
return GitUri.file(this.resolve(fileName, repoPath));
static resolve(fileName: string, repoPath?: string) {
return GitUri.file(this.resolvePath(fileName, repoPath));
} }
static toKey(fileName: string): string; static toKey(fileName: string): string;
@ -466,7 +460,7 @@ export class GitUri extends (Uri as any as UriEx) {
fileName = fileNameOrFile; fileName = fileNameOrFile;
} else { } else {
//if (fileNameOrFile!.status === 'D') { //if (fileNameOrFile!.status === 'D') {
fileName = GitUri.resolve(fileNameOrFile!.originalFileName ?? fileNameOrFile!.fileName, repoPath);
fileName = GitUri.resolvePath(fileNameOrFile!.originalFileName ?? fileNameOrFile!.fileName, repoPath);
// } else { // } else {
// fileName = GitUri.resolve(fileNameOrFile!.fileName, repoPath); // fileName = GitUri.resolve(fileNameOrFile!.fileName, repoPath);
} }

+ 3
- 3
src/git/models/commit.ts Переглянути файл

@ -126,7 +126,7 @@ export abstract class GitCommit implements GitRevisionReference {
@memoize() @memoize()
get originalUri(): Uri { get originalUri(): Uri {
return this.originalFileName ? GitUri.resolveToUri(this.originalFileName, this.repoPath) : this.uri;
return this.originalFileName ? GitUri.resolve(this.originalFileName, this.repoPath) : this.uri;
} }
get previousFileSha(): string { get previousFileSha(): string {
@ -138,12 +138,12 @@ export abstract class GitCommit implements GitRevisionReference {
} }
get previousUri(): Uri { get previousUri(): Uri {
return this.previousFileName ? GitUri.resolveToUri(this.previousFileName, this.repoPath) : this.uri;
return this.previousFileName ? GitUri.resolve(this.previousFileName, this.repoPath) : this.uri;
} }
@memoize() @memoize()
get uri(): Uri { get uri(): Uri {
return GitUri.resolveToUri(this.fileName, this.repoPath);
return GitUri.resolve(this.fileName, this.repoPath);
} }
@memoize() @memoize()

+ 1
- 1
src/git/models/logCommit.ts Переглянути файл

@ -90,7 +90,7 @@ export class GitLogCommit extends GitCommit {
} }
get nextUri(): Uri { get nextUri(): Uri {
return this.nextFileName ? GitUri.resolveToUri(this.nextFileName, this.repoPath) : this.uri;
return this.nextFileName ? GitUri.resolve(this.nextFileName, this.repoPath) : this.uri;
} }
override get previousFileSha(): string { override get previousFileSha(): string {

+ 1
- 1
src/git/models/status.ts Переглянути файл

@ -403,7 +403,7 @@ export class GitStatusFile implements GitFile {
@memoize() @memoize()
get uri(): Uri { get uri(): Uri {
return GitUri.resolveToUri(this.fileName, this.repoPath);
return GitUri.resolve(this.fileName, this.repoPath);
} }
getFormattedDirectory(includeOriginal: boolean = false): string { getFormattedDirectory(includeOriginal: boolean = false): string {

+ 2
- 2
src/views/nodes/mergeConflictFileNode.ts Переглянути файл

@ -53,7 +53,7 @@ export class MergeConflictFileNode extends ViewNode implements
this.file, this.file,
); );
// Use the file icon and decorations // Use the file icon and decorations
item.resourceUri = GitUri.resolveToUri(this.file.fileName, this.repoPath);
item.resourceUri = GitUri.resolve(this.file.fileName, this.repoPath);
item.iconPath = ThemeIcon.File; item.iconPath = ThemeIcon.File;
item.command = this.getCommand(); item.command = this.getCommand();
@ -115,7 +115,7 @@ export class MergeConflictFileNode extends ViewNode implements
title: 'Open File', title: 'Open File',
command: BuiltInCommands.Open, command: BuiltInCommands.Open,
arguments: [ arguments: [
GitUri.resolveToUri(this.file.fileName, this.repoPath),
GitUri.resolve(this.file.fileName, this.repoPath),
{ {
preserveFocus: true, preserveFocus: true,
preview: true, preview: true,

+ 2
- 2
src/views/nodes/statusFileNode.ts Переглянути файл

@ -87,7 +87,7 @@ export class StatusFileNode extends ViewNode implements FileNo
} }
// Use the file icon and decorations // Use the file icon and decorations
item.resourceUri = GitUri.resolveToUri(this.file.fileName, this.repoPath);
item.resourceUri = GitUri.resolve(this.file.fileName, this.repoPath);
item.iconPath = ThemeIcon.File; item.iconPath = ThemeIcon.File;
item.command = this.getCommand(); item.command = this.getCommand();
@ -104,7 +104,7 @@ export class StatusFileNode extends ViewNode implements FileNo
} }
// Use the file icon and decorations // Use the file icon and decorations
item.resourceUri = GitUri.resolveToUri(this.file.fileName, this.repoPath);
item.resourceUri = GitUri.resolve(this.file.fileName, this.repoPath);
item.iconPath = ThemeIcon.File; item.iconPath = ThemeIcon.File;
} else { } else {
item.contextValue = ContextValues.StatusFileCommits; item.contextValue = ContextValues.StatusFileCommits;

+ 1
- 1
src/vsls/host.ts Переглянути файл

@ -155,7 +155,7 @@ export class VslsHostService implements Disposable {
const localCwd = this._sharedToLocalPaths.get('/~0'); const localCwd = this._sharedToLocalPaths.get('/~0');
if (localCwd !== undefined) { if (localCwd !== undefined) {
isRootWorkspace = true; isRootWorkspace = true;
options.cwd = GitUri.resolve(options.cwd, localCwd);
options.cwd = GitUri.resolvePath(options.cwd, localCwd);
} }
} }
} }

Завантаження…
Відмінити
Зберегти