Ver a proveniência

Renames GitUri resolve/resolveToUri

main
Eric Amodio há 2 anos
ascendente
cometimento
817360ca6c
9 ficheiros alterados com 34 adições e 40 eliminações
  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 Ver ficheiro

@ -86,7 +86,7 @@ export class DiffWithRevisionFromCommand extends ActiveEditorCommand {
const fileName = normalizePath(relative(gitUri.repoPath, gitUri.fsPath));
const rename = files.find(s => s.fileName === fileName);
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)})`;
}
}

+ 3
- 3
src/env/node/git/localGitProvider.ts Ver ficheiro

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

+ 20
- 26
src/git/gitUri.ts Ver ficheiro

@ -99,10 +99,20 @@ export class GitUri extends (Uri as any as UriEx) {
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;
switch (uri.scheme) {
@ -198,22 +208,6 @@ export class GitUri extends (Uri as any as UriEx) {
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) {
const uri = Uri.file(path);
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 {
const uri = GitUri.resolveToUri(
const uri = GitUri.resolve(
typeof file === 'string' ? file : (original && file.originalFileName) || file.fileName,
repoPath,
);
@ -413,7 +407,7 @@ export class GitUri extends (Uri as any as UriEx) {
}
static git(fileName: string, repoPath?: string) {
const path = GitUri.resolve(fileName, repoPath);
const path = GitUri.resolvePath(fileName, repoPath);
return Uri.parse(
// Change encoded / back to / otherwise uri parsing won't work properly
`${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);
if (repoPath === undefined) return normalizedFileName;
@ -438,8 +432,8 @@ export class GitUri extends (Uri as any as UriEx) {
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;
@ -466,7 +460,7 @@ export class GitUri extends (Uri as any as UriEx) {
fileName = fileNameOrFile;
} else {
//if (fileNameOrFile!.status === 'D') {
fileName = GitUri.resolve(fileNameOrFile!.originalFileName ?? fileNameOrFile!.fileName, repoPath);
fileName = GitUri.resolvePath(fileNameOrFile!.originalFileName ?? fileNameOrFile!.fileName, repoPath);
// } else {
// fileName = GitUri.resolve(fileNameOrFile!.fileName, repoPath);
}

+ 3
- 3
src/git/models/commit.ts Ver ficheiro

@ -126,7 +126,7 @@ export abstract class GitCommit implements GitRevisionReference {
@memoize()
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 {
@ -138,12 +138,12 @@ export abstract class GitCommit implements GitRevisionReference {
}
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()
get uri(): Uri {
return GitUri.resolveToUri(this.fileName, this.repoPath);
return GitUri.resolve(this.fileName, this.repoPath);
}
@memoize()

+ 1
- 1
src/git/models/logCommit.ts Ver ficheiro

@ -90,7 +90,7 @@ export class GitLogCommit extends GitCommit {
}
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 {

+ 1
- 1
src/git/models/status.ts Ver ficheiro

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

+ 2
- 2
src/views/nodes/mergeConflictFileNode.ts Ver ficheiro

@ -53,7 +53,7 @@ export class MergeConflictFileNode extends ViewNode implements
this.file,
);
// 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.command = this.getCommand();
@ -115,7 +115,7 @@ export class MergeConflictFileNode extends ViewNode implements
title: 'Open File',
command: BuiltInCommands.Open,
arguments: [
GitUri.resolveToUri(this.file.fileName, this.repoPath),
GitUri.resolve(this.file.fileName, this.repoPath),
{
preserveFocus: true,
preview: true,

+ 2
- 2
src/views/nodes/statusFileNode.ts Ver ficheiro

@ -87,7 +87,7 @@ export class StatusFileNode extends ViewNode implements FileNo
}
// 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.command = this.getCommand();
@ -104,7 +104,7 @@ export class StatusFileNode extends ViewNode implements FileNo
}
// 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;
} else {
item.contextValue = ContextValues.StatusFileCommits;

+ 1
- 1
src/vsls/host.ts Ver ficheiro

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

Carregando…
Cancelar
Guardar