Browse Source

Fixes relative paths when repoPath is missing

Renames path import to paths for less naming conflicts
main
Eric Amodio 6 years ago
parent
commit
b2750e9654
30 changed files with 119 additions and 116 deletions
  1. +2
    -2
      src/annotations/fileAnnotationController.ts
  2. +2
    -2
      src/commands/common.ts
  3. +3
    -3
      src/commands/diffWith.ts
  4. +6
    -6
      src/commands/diffWithBranch.ts
  5. +2
    -2
      src/commands/openWorkingFile.ts
  6. +3
    -3
      src/commands/showQuickCommitDetails.ts
  7. +3
    -3
      src/commands/showQuickCommitFileDetails.ts
  8. +2
    -2
      src/commands/showQuickFileHistory.ts
  9. +2
    -2
      src/git/formatters/statusFormatter.ts
  10. +20
    -17
      src/git/gitUri.ts
  11. +2
    -2
      src/git/locator.ts
  12. +4
    -4
      src/git/models/commit.ts
  13. +3
    -3
      src/git/models/logCommit.ts
  14. +2
    -2
      src/git/models/status.ts
  15. +2
    -2
      src/git/parsers/blameParser.ts
  16. +2
    -2
      src/git/parsers/logParser.ts
  17. +5
    -5
      src/git/shell.ts
  18. +13
    -13
      src/quickpicks/commitFileQuickPick.ts
  19. +2
    -2
      src/quickpicks/commitQuickPick.ts
  20. +6
    -6
      src/quickpicks/fileHistoryQuickPick.ts
  21. +5
    -5
      src/quickpicks/remotesQuickPick.ts
  22. +2
    -2
      src/quickpicks/repoStatusQuickPick.ts
  23. +6
    -6
      src/views/nodes/commitFileNode.ts
  24. +2
    -2
      src/views/nodes/commitNode.ts
  25. +2
    -2
      src/views/nodes/fileHistoryTrackerNode.ts
  26. +4
    -4
      src/views/nodes/resultsFileNode.ts
  27. +2
    -2
      src/views/nodes/resultsFilesNode.ts
  28. +6
    -6
      src/views/nodes/statusFileNode.ts
  29. +2
    -2
      src/views/nodes/statusFilesNode.ts
  30. +2
    -2
      src/views/viewCommands.ts

+ 2
- 2
src/annotations/fileAnnotationController.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import {
ConfigurationChangeEvent,
DecorationRangeBehavior,
@ -490,7 +490,7 @@ export class FileAnnotationController implements Disposable {
}
progress!.report({
message: `Computing ${annotationsLabel} for ${path.basename(editor.document.fileName)}`
message: `Computing ${annotationsLabel} for ${paths.basename(editor.document.fileName)}`
});
}

+ 2
- 2
src/commands/common.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import {
commands,
Disposable,
@ -489,7 +489,7 @@ export async function openEditor(
uri = uri.documentUri({ noSha: true });
}
if (uri.scheme === DocumentSchemes.GitLens && ImageMimetypes[path.extname(uri.fsPath)]) {
if (uri.scheme === DocumentSchemes.GitLens && ImageMimetypes[paths.extname(uri.fsPath)]) {
await commands.executeCommand(BuiltInCommands.Open, uri);
return undefined;

+ 3
- 3
src/commands/diffWith.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, ViewColumn } from 'vscode';
import { BuiltInCommands, GlyphChars } from '../constants';
import { Container } from '../container';
@ -157,10 +157,10 @@ export class DiffWithCommand extends ActiveEditorCommand {
}
if (args.lhs.title === undefined && (lhs !== undefined || lhsSuffix !== '')) {
args.lhs.title = `${path.basename(args.lhs.uri.fsPath)}${lhsSuffix ? ` (${lhsSuffix})` : ''}`;
args.lhs.title = `${paths.basename(args.lhs.uri.fsPath)}${lhsSuffix ? ` (${lhsSuffix})` : ''}`;
}
if (args.rhs.title === undefined) {
args.rhs.title = `${path.basename(args.rhs.uri.fsPath)}${rhsSuffix ? ` (${rhsSuffix})` : ''}`;
args.rhs.title = `${paths.basename(args.rhs.uri.fsPath)}${rhsSuffix ? ` (${rhsSuffix})` : ''}`;
}
const title =

+ 6
- 6
src/commands/diffWithBranch.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { commands, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
@ -34,7 +34,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
const gitUri = await GitUri.fromUri(uri);
if (!gitUri.repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to open file compare`);
const placeHolder = `Compare ${path.basename(gitUri.fsPath)} with${GlyphChars.Ellipsis}`;
const placeHolder = `Compare ${paths.basename(gitUri.fsPath)} with${GlyphChars.Ellipsis}`;
const progressCancellation = BranchesAndTagsQuickPick.showProgress(placeHolder);
try {
@ -62,11 +62,11 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
// Check to see if this file has been renamed
const files = await Container.git.getDiffStatus(gitUri.repoPath, 'HEAD', ref, { filter: 'R' });
if (files !== undefined) {
const fileName = Strings.normalizePath(path.relative(gitUri.repoPath, gitUri.fsPath));
const fileName = Strings.normalizePath(paths.relative(gitUri.repoPath, gitUri.fsPath));
const rename = files.find(s => s.fileName === fileName);
if (rename !== undefined && rename.originalFileName !== undefined) {
renamedUri = Uri.file(path.join(gitUri.repoPath, rename.originalFileName));
renamedTitle = `${path.basename(rename.originalFileName)} (${ref})`;
renamedUri = Uri.file(paths.join(gitUri.repoPath, rename.originalFileName));
renamedTitle = `${paths.basename(rename.originalFileName)} (${ref})`;
}
}
@ -75,7 +75,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
lhs: {
sha: pick.remote ? `remotes/${ref}` : ref,
uri: renamedUri || (gitUri as Uri),
title: renamedTitle || `${path.basename(gitUri.fsPath)} (${ref})`
title: renamedTitle || `${paths.basename(gitUri.fsPath)} (${ref})`
},
rhs: {
sha: '',

+ 2
- 2
src/commands/openWorkingFile.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { FileAnnotationType } from '../configuration';
import { Container } from '../container';
@ -43,7 +43,7 @@ export class OpenWorkingFileCommand extends ActiveEditorCommand {
);
}
args.uri = new GitUri(Uri.file(path.resolve(repoPath || '', fileName)), repoPath);
args.uri = new GitUri(Uri.file(paths.resolve(repoPath || '', fileName)), repoPath);
}
}

+ 3
- 3
src/commands/showQuickCommitDetails.ts View File

@ -1,6 +1,6 @@
'use strict';
import * as path from 'path';
import { commands, TextEditor, Uri, window } from 'vscode';
import * as paths from 'path';
import { commands, TextEditor, Uri } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitCommit, GitLog, GitLogCommit, GitUri } from '../git/gitService';
@ -73,7 +73,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
const gitUri = await GitUri.fromUri(uri);
let repoPath = gitUri.repoPath;
let workingFileName = path.relative(repoPath || '', gitUri.fsPath);
let workingFileName = repoPath ? paths.relative(repoPath , gitUri.fsPath) : gitUri.fsPath;
args = { ...args };
if (args.sha === undefined) {

+ 3
- 3
src/commands/showQuickCommitFileDetails.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { TextEditor, Uri, window } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
@ -84,7 +84,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
args.sha = blame.commit.sha;
args.commit = blame.commit;
workingFileName = path.relative(args.commit.repoPath, gitUri.fsPath);
workingFileName = paths.relative(args.commit.repoPath, gitUri.fsPath);
}
catch (ex) {
Logger.error(ex, 'ShowQuickCommitFileDetailsCommand', `getBlameForLine(${blameline})`);
@ -156,7 +156,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to details of ${
GlyphChars.Space
}$(file-text) ${path.basename(args.commit.fileName)} in ${
}$(file-text) ${paths.basename(args.commit.fileName)} in ${
GlyphChars.Space
}$(git-commit) ${shortSha}`
},

+ 2
- 2
src/commands/showQuickFileHistory.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
@ -122,7 +122,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${
GlyphChars.Space
}$(file-text) ${path.basename(gitUri.fsPath)}${
}$(file-text) ${paths.basename(gitUri.fsPath)}${
args.branchOrTag
? ` from ${GlyphChars.Space}${
args.branchOrTag instanceof GitTag ? '$(tag)' : '$(git-branch)'

+ 2
- 2
src/git/formatters/statusFormatter.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { GlyphChars } from '../../constants';
import { Strings } from '../../system';
import { GitFile, GitFileWithCommit } from '../models/file';
@ -25,7 +25,7 @@ export class StatusFileFormatter extends Formatter
}
get file() {
const file = path.basename(this._item.fileName);
const file = paths.basename(this._item.fileName);
return this._padOrTruncate(file, this._options.tokenOptions!.file);
}

+ 20
- 17
src/git/gitUri.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Uri } from 'vscode';
import { UriComparer } from '../comparers';
import { DocumentSchemes, GlyphChars } from '../constants';
@ -87,7 +87,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
const [authority, fsPath] = GitUri.ensureValidUNCPath(
uri.authority,
path.resolve(commitOrRepoPath.repoPath, commitOrRepoPath.fileName || uri.fsPath)
paths.resolve(commitOrRepoPath.repoPath, commitOrRepoPath.fileName || uri.fsPath)
);
super({ scheme: uri.scheme, authority: authority, path: fsPath, query: uri.query, fragment: uri.fragment });
@ -115,24 +115,27 @@ export class GitUri extends ((Uri as any) as UriEx) {
}
getDirectory(relativeTo?: string): string {
return GitUri.getDirectory(path.relative(this.repoPath || '', this.fsPath), relativeTo);
return GitUri.getDirectory(
this.repoPath ? paths.relative(this.repoPath, this.fsPath) : this.fsPath,
relativeTo
);
}
getFilename(relativeTo?: string): string {
return path.basename(path.relative(this.repoPath || '', this.fsPath), relativeTo);
return paths.basename(this.repoPath ? paths.relative(this.repoPath, this.fsPath) : this.fsPath, relativeTo);
}
getFormattedPath(options: { relativeTo?: string; separator?: string; suffix?: string } = {}): string {
const { relativeTo = this.repoPath, separator = Strings.pad(GlyphChars.Dot, 2, 2), suffix = '' } = options;
const directory = GitUri.getDirectory(this.fsPath, relativeTo);
return `${path.basename(this.fsPath)}${suffix}${directory ? `${separator}${directory}` : ''}`;
return `${paths.basename(this.fsPath)}${suffix}${directory ? `${separator}${directory}` : ''}`;
}
getRelativePath(relativeTo?: string): string {
let relativePath = path.relative(this.repoPath || '', this.fsPath);
let relativePath = this.repoPath ? paths.relative(this.repoPath, this.fsPath) : this.fsPath;
if (relativeTo !== undefined) {
relativePath = path.relative(relativeTo, relativePath);
relativePath = paths.relative(relativeTo, relativePath);
}
return Strings.normalizePath(relativePath);
}
@ -168,7 +171,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
}
static fromFile(file: GitFile, repoPath: string, ref?: string, original: boolean = false): GitUri {
const uri = Uri.file(path.resolve(repoPath, (original && file.originalFileName) || file.fileName));
const uri = Uri.file(paths.resolve(repoPath, (original && file.originalFileName) || file.fileName));
return ref === undefined ? new GitUri(uri, repoPath) : new GitUri(uri, { repoPath: repoPath, sha: ref });
}
@ -222,9 +225,9 @@ export class GitUri extends ((Uri as any) as UriEx) {
}
static getDirectory(fileName: string, relativeTo?: string): string {
let directory: string | undefined = path.dirname(fileName);
let directory: string | undefined = paths.dirname(fileName);
if (relativeTo !== undefined) {
directory = path.relative(relativeTo, directory);
directory = paths.relative(relativeTo, directory);
}
directory = Strings.normalizePath(directory);
return !directory || directory === '.' ? '' : directory;
@ -248,8 +251,8 @@ export class GitUri extends ((Uri as any) as UriEx) {
const directory = GitUri.getDirectory(fileName, relativeTo);
return !directory
? `${path.basename(fileName)}${suffix}`
: `${path.basename(fileName)}${suffix}${separator}${directory}`;
? `${paths.basename(fileName)}${suffix}`
: `${paths.basename(fileName)}${suffix}${separator}${directory}`;
}
static getRelativePath(fileNameOrUri: string | Uri, relativeTo?: string, repoPath?: string): string {
@ -263,9 +266,9 @@ export class GitUri extends ((Uri as any) as UriEx) {
fileName = fileNameOrUri;
}
let relativePath = path.relative(repoPath || '', fileName);
let relativePath = repoPath ? paths.relative(repoPath, fileName) : fileName;
if (relativeTo !== undefined) {
relativePath = path.relative(relativeTo, relativePath);
relativePath = paths.relative(relativeTo, relativePath);
}
return Strings.normalizePath(relativePath);
}
@ -292,7 +295,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
fileName = fileNameOrFile;
}
else {
fileName = path.resolve(repoPath!, fileNameOrFile!.fileName);
fileName = paths.resolve(repoPath!, fileNameOrFile!.fileName);
}
ref = uriOrRef;
@ -306,14 +309,14 @@ export class GitUri extends ((Uri as any) as UriEx) {
}
repoPath = Strings.normalizePath(repoPath!);
const repoName = path.basename(repoPath);
const repoName = paths.basename(repoPath);
const data: IUriRevisionData = {
path: Strings.normalizePath(fileName, { addLeadingSlash: true }),
ref: ref,
repoPath: repoPath
};
let filePath = Strings.normalizePath(path.relative(repoPath, fileName), { addLeadingSlash: true });
let filePath = Strings.normalizePath(paths.relative(repoPath, fileName), { addLeadingSlash: true });
if (filePath === '/') {
filePath = '';
}

+ 2
- 2
src/git/locator.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { findExecutable, run } from './shell';
export interface GitLocation {
@ -51,7 +51,7 @@ async function findGitDarwin(): Promise {
function findSystemGitWin32(basePath: string): Promise<GitLocation> {
if (!basePath) return Promise.reject(new Error('Unable to find git'));
return findSpecificGit(path.join(basePath, 'Git', 'cmd', 'git.exe'));
return findSpecificGit(paths.join(basePath, 'Git', 'cmd', 'git.exe'));
}
function findGitWin32(): Promise<GitLocation> {

+ 4
- 4
src/git/models/commit.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Uri } from 'vscode';
import { configuration, DateStyle, GravatarDefaultStyle } from '../../configuration';
import { Container } from '../../container';
@ -144,16 +144,16 @@ export abstract class GitCommit {
get previousUri(): Uri {
return this.previousFileName
? Uri.file(path.resolve(this.repoPath, (this.previousFileName || this.originalFileName)!))
? Uri.file(paths.resolve(this.repoPath, (this.previousFileName || this.originalFileName)!))
: this.uri;
}
get uri(): Uri {
return Uri.file(path.resolve(this.repoPath, this.fileName));
return Uri.file(paths.resolve(this.repoPath, this.fileName));
}
get workingUri(): Uri {
return this.workingFileName ? Uri.file(path.resolve(this.repoPath, this.workingFileName)) : this.uri;
return this.workingFileName ? Uri.file(paths.resolve(this.repoPath, this.workingFileName)) : this.uri;
}
private _dateFormatter?: Dates.IDateFormatter;

+ 3
- 3
src/git/models/logCommit.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Uri } from 'vscode';
import { Strings } from '../../system';
import { Git } from '../git';
@ -51,7 +51,7 @@ export class GitLogCommit extends GitCommit {
}
get nextUri(): Uri {
return this.nextFileName ? Uri.file(path.resolve(this.repoPath, this.nextFileName)) : this.uri;
return this.nextFileName ? Uri.file(paths.resolve(this.repoPath, this.nextFileName)) : this.uri;
}
get previousFileSha(): string {
@ -133,7 +133,7 @@ export class GitLogCommit extends GitCommit {
toFileCommit(fileNameOrFile: string | GitFile): GitLogCommit | undefined {
let file: GitFile | undefined;
if (typeof fileNameOrFile === 'string') {
const fileName = Strings.normalizePath(path.relative(this.repoPath, fileNameOrFile));
const fileName = Strings.normalizePath(paths.relative(this.repoPath, fileNameOrFile));
file = this.files.find(f => f.fileName === fileName);
if (file === undefined) return undefined;
}

+ 2
- 2
src/git/models/status.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Uri } from 'vscode';
import { GlyphChars } from '../../constants';
import { Strings } from '../../system';
@ -153,7 +153,7 @@ export class GitStatusFile implements GitFile {
}
get uri(): Uri {
return Uri.file(path.resolve(this.repoPath, this.fileName));
return Uri.file(paths.resolve(this.repoPath, this.fileName));
}
getFormattedDirectory(includeOriginal: boolean = false): string {

+ 2
- 2
src/git/parsers/blameParser.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Strings } from '../../system';
import { Git, GitAuthor, GitBlame, GitBlameCommit, GitCommitLine } from './../git';
@ -123,7 +123,7 @@ export class GitBlameParser {
repoPath = Strings.normalizePath(
fileName.replace(fileName.startsWith('/') ? `/${entry.fileName}` : entry.fileName!, '')
);
relativeFileName = Strings.normalizePath(path.relative(repoPath, fileName));
relativeFileName = Strings.normalizePath(paths.relative(repoPath, fileName));
}
first = false;

+ 2
- 2
src/git/parsers/logParser.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Range } from 'vscode';
import { Arrays, Strings } from '../../system';
import { Git, GitAuthor, GitCommitType, GitFile, GitFileStatus, GitLog, GitLogCommit } from './../git';
@ -197,7 +197,7 @@ export class GitLogParser {
repoPath = Strings.normalizePath(
fileName.replace(fileName.startsWith('/') ? `/${entry.fileName}` : entry.fileName!, '')
);
relativeFileName = Strings.normalizePath(path.relative(repoPath, fileName));
relativeFileName = Strings.normalizePath(paths.relative(repoPath, fileName));
}
else {
relativeFileName = entry.fileName!;

+ 5
- 5
src/git/shell.ts View File

@ -2,7 +2,7 @@
import { execFile } from 'child_process';
import * as fs from 'fs';
import * as iconv from 'iconv-lite';
import * as path from 'path';
import * as paths from 'path';
import { Logger } from '../logger';
const isWindows = process.platform === 'win32';
@ -23,7 +23,7 @@ function runDownPath(exe: string): string {
// Files with any directory path don't get this applied
if (exe.match(/[\\\/]/)) return exe;
const target = path.join('.', exe);
const target = paths.join('.', exe);
try {
if (fs.statSync(target)) return target;
}
@ -31,7 +31,7 @@ function runDownPath(exe: string): string {
const haystack = process.env.PATH!.split(isWindows ? ';' : ':');
for (const p of haystack) {
const needle = path.join(p, exe);
const needle = paths.join(p, exe);
try {
if (fs.statSync(needle)) return needle;
}
@ -67,14 +67,14 @@ export function findExecutable(exe: string, args: string[]): { cmd: string; args
}
if (exe.match(/\.ps1$/i)) {
const cmd = path.join(process.env.SYSTEMROOT!, 'System32', 'WindowsPowerShell', 'v1.0', 'PowerShell.exe');
const cmd = paths.join(process.env.SYSTEMROOT!, 'System32', 'WindowsPowerShell', 'v1.0', 'PowerShell.exe');
const psargs = ['-ExecutionPolicy', 'Unrestricted', '-NoLogo', '-NonInteractive', '-File', exe];
return { cmd: cmd, args: psargs.concat(args) };
}
if (exe.match(/\.(bat|cmd)$/i)) {
const cmd = path.join(process.env.SYSTEMROOT!, 'System32', 'cmd.exe');
const cmd = paths.join(process.env.SYSTEMROOT!, 'System32', 'cmd.exe');
const cmdArgs = ['/C', exe, ...args];
return { cmd: cmd, args: cmdArgs };

+ 13
- 13
src/quickpicks/commitFileQuickPick.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import {
Commands,
@ -33,9 +33,9 @@ export class ApplyCommitFileChangesCommandQuickPickItem extends CommandQuickPick
super(
item || {
label: `$(git-pull-request) Apply Changes`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(file-text) ${path.basename(commit.fileName)} in ${
GlyphChars.Space
}$(git-commit) ${commit.shortSha}`
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} $(file-text) ${paths.basename(
commit.fileName
)} in ${GlyphChars.Space}$(git-commit) ${commit.shortSha}`
},
undefined,
undefined
@ -54,12 +54,12 @@ export class ApplyCommitFileChangesCommandQuickPickItem extends CommandQuickPick
export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
constructor(commit: GitLogCommit, item?: QuickPickItem) {
const uri = Uri.file(path.resolve(commit.repoPath, commit.fileName));
const uri = Uri.file(paths.resolve(commit.repoPath, commit.fileName));
super(
uri,
item || {
label: `$(file-symlink-file) Open File`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${path.basename(commit.fileName)}`
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${paths.basename(commit.fileName)}`
}
);
}
@ -71,13 +71,13 @@ export class OpenCommitFileRevisionCommandQuickPickItem extends OpenFileCommandQ
let uri: Uri;
if (commit.status === 'D') {
uri = GitUri.toRevisionUri(commit.previousFileSha, commit.previousUri.fsPath, commit.repoPath);
description = `${Strings.pad(GlyphChars.Dash, 2, 3)} ${path.basename(commit.fileName)} in ${
description = `${Strings.pad(GlyphChars.Dash, 2, 3)} ${paths.basename(commit.fileName)} in ${
GlyphChars.Space
}$(git-commit) ${commit.previousShortSha} (deleted in ${GlyphChars.Space}$(git-commit) ${commit.shortSha})`;
}
else {
uri = GitUri.toRevisionUri(commit.sha, commit.uri.fsPath, commit.repoPath);
description = `${Strings.pad(GlyphChars.Dash, 2, 3)} ${path.basename(commit.fileName)} in ${
description = `${Strings.pad(GlyphChars.Dash, 2, 3)} ${paths.basename(commit.fileName)} in ${
GlyphChars.Space
}$(git-commit) ${commit.shortSha}`;
}
@ -104,7 +104,7 @@ export class CommitFileQuickPick {
const stash = commit.isStash;
const workingName =
(commit.workingFileName && path.basename(commit.workingFileName)) || path.basename(commit.fileName);
(commit.workingFileName && paths.basename(commit.workingFileName)) || paths.basename(commit.fileName);
const isUncommitted = commit.isUncommitted;
if (isUncommitted) {
@ -152,7 +152,7 @@ export class CommitFileQuickPick {
},
Commands.DiffWithWorking,
[
Uri.file(path.resolve(commit.repoPath, commit.workingFileName)),
Uri.file(paths.resolve(commit.repoPath, commit.workingFileName)),
{
commit
} as DiffWithWorkingCommandArgs
@ -242,11 +242,11 @@ export class CommitFileQuickPick {
new CommandQuickPickItem(
{
label: `$(history) Show File History`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${path.basename(commit.fileName)}`
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${paths.basename(commit.fileName)}`
},
Commands.ShowQuickFileHistory,
[
Uri.file(path.resolve(commit.repoPath, commit.workingFileName)),
Uri.file(paths.resolve(commit.repoPath, commit.workingFileName)),
{
fileLog,
goBackCommand: currentCommand
@ -261,7 +261,7 @@ export class CommitFileQuickPick {
new CommandQuickPickItem(
{
label: `$(history) Show ${commit.workingFileName ? 'Previous ' : ''}File History`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${path.basename(
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${paths.basename(
commit.fileName
)} ${Strings.pad(GlyphChars.Dot, 1, 1)} from ${GlyphChars.Space}$(git-commit) ${
commit.shortSha

+ 2
- 2
src/quickpicks/commitQuickPick.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from 'vscode';
import {
Commands,
@ -45,7 +45,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
const description = GitFile.getFormattedDirectory(file, true);
super(GitUri.toRevisionUri(commit.sha, file, commit.repoPath), {
label: `${Strings.pad(octicon, 4, 2)} ${path.basename(file.fileName)}`,
label: `${Strings.pad(octicon, 4, 2)} ${paths.basename(file.fileName)}`,
description: description
});

+ 6
- 6
src/quickpicks/fileHistoryQuickPick.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { CancellationTokenSource, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, ShowQuickCurrentBranchHistoryCommandArgs, ShowQuickFileHistoryCommandArgs } from '../commands';
import { GlyphChars } from '../constants';
@ -67,7 +67,7 @@ export class FileHistoryQuickPick {
}
else if (!options.pickerOnly) {
const [workingFileName] = await Container.git.findWorkingFileName(
path.relative(log.repoPath, uri.fsPath),
paths.relative(log.repoPath, uri.fsPath),
log.repoPath
);
if (workingFileName) {
@ -78,20 +78,20 @@ export class FileHistoryQuickPick {
new CommandQuickPickItem(
{
label: `$(history) Show File History`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${path.basename(
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} of ${paths.basename(
workingFileName
)}`
},
Commands.ShowQuickFileHistory,
[
Uri.file(path.resolve(log.repoPath, workingFileName)),
Uri.file(paths.resolve(log.repoPath, workingFileName)),
{
goBackCommand: new CommandQuickPickItem(
{
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${
GlyphChars.Space
}$(file-text) ${path.basename(uri.fsPath)}${
}$(file-text) ${paths.basename(uri.fsPath)}${
uri.sha ? ` from ${GlyphChars.Space}$(git-commit) ${uri.shortSha}` : ''
}`
},
@ -133,7 +133,7 @@ export class FileHistoryQuickPick {
label: `go back ${GlyphChars.ArrowBack}`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} to history of ${
GlyphChars.Space
}$(file-text) ${path.basename(uri.fsPath)}${
}$(file-text) ${paths.basename(uri.fsPath)}${
uri.sha ? ` from ${GlyphChars.Space}$(git-commit) ${uri.shortSha}` : ''
}`
},

+ 5
- 5
src/quickpicks/remotesQuickPick.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { QuickPickOptions, window } from 'vscode';
import { Commands, OpenInRemoteCommandArgs } from '../commands';
import { GlyphChars } from '../constants';
@ -67,7 +67,7 @@ export class OpenRemotesCommandQuickPickItem extends CommandQuickPickItem {
break;
case RemoteResourceType.File:
description = `$(file-text) ${path.basename(resource.fileName)}`;
description = `$(file-text) ${paths.basename(resource.fileName)}`;
break;
case RemoteResourceType.Repo:
@ -78,7 +78,7 @@ export class OpenRemotesCommandQuickPickItem extends CommandQuickPickItem {
if (resource.commit !== undefined && resource.commit instanceof GitLogCommit) {
if (resource.commit.status === 'D') {
resource.sha = resource.commit.previousSha;
description = `$(file-text) ${path.basename(resource.fileName)} in ${
description = `$(file-text) ${paths.basename(resource.fileName)} in ${
GlyphChars.Space
}$(git-commit) ${resource.commit.previousShortSha} (deleted in ${
GlyphChars.Space
@ -86,14 +86,14 @@ export class OpenRemotesCommandQuickPickItem extends CommandQuickPickItem {
}
else {
resource.sha = resource.commit.sha;
description = `$(file-text) ${path.basename(resource.fileName)} in ${
description = `$(file-text) ${paths.basename(resource.fileName)} in ${
GlyphChars.Space
}$(git-commit) ${resource.commit.shortSha}`;
}
}
else {
const shortFileSha = resource.sha === undefined ? '' : GitService.shortenSha(resource.sha);
description = `$(file-text) ${path.basename(resource.fileName)}${
description = `$(file-text) ${paths.basename(resource.fileName)}${
shortFileSha ? ` in ${GlyphChars.Space}$(git-commit) ${shortFileSha}` : ''
}`;
}

+ 2
- 2
src/quickpicks/repoStatusQuickPick.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { commands, QuickPickOptions, TextDocumentShowOptions, window } from 'vscode';
import {
Commands,
@ -44,7 +44,7 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
octicon,
2,
2
)} ${path.basename(status.fileName)}`,
)} ${paths.basename(status.fileName)}`,
description: description
}
);

+ 6
- 6
src/views/nodes/commitFileNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Command, Selection, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Commands, DiffWithPreviousCommandArgs } from '../../commands';
import { GlyphChars } from '../../constants';
@ -75,15 +75,15 @@ export class CommitFileNode extends ViewRefNode {
if ((this._displayAs & CommitFileNodeDisplayAs.CommitIcon) === CommitFileNodeDisplayAs.CommitIcon) {
item.iconPath = {
dark: Container.context.asAbsolutePath(path.join('images', 'dark', 'icon-commit.svg')),
light: Container.context.asAbsolutePath(path.join('images', 'light', 'icon-commit.svg'))
dark: Container.context.asAbsolutePath(paths.join('images', 'dark', 'icon-commit.svg')),
light: Container.context.asAbsolutePath(paths.join('images', 'light', 'icon-commit.svg'))
};
}
else if ((this._displayAs & CommitFileNodeDisplayAs.StatusIcon) === CommitFileNodeDisplayAs.StatusIcon) {
const icon = GitFile.getStatusIcon(this.file.status);
item.iconPath = {
dark: Container.context.asAbsolutePath(path.join('images', 'dark', icon)),
light: Container.context.asAbsolutePath(path.join('images', 'light', icon))
dark: Container.context.asAbsolutePath(paths.join('images', 'dark', icon)),
light: Container.context.asAbsolutePath(paths.join('images', 'light', icon))
};
}
else if ((this._displayAs & CommitFileNodeDisplayAs.Gravatar) === CommitFileNodeDisplayAs.Gravatar) {
@ -102,7 +102,7 @@ export class CommitFileNode extends ViewRefNode {
private _folderName: string | undefined;
get folderName() {
if (this._folderName === undefined) {
this._folderName = path.dirname(this.uri.getRelativePath());
this._folderName = paths.dirname(this.uri.getRelativePath());
}
return this._folderName;
}

+ 2
- 2
src/views/nodes/commitNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Command, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Commands, DiffWithPreviousCommandArgs } from '../../commands';
import { ViewFilesLayout } from '../../configuration';
@ -40,7 +40,7 @@ export class CommitNode extends ViewRefNode {
const hierarchy = Arrays.makeHierarchical(
children,
n => n.uri.getRelativePath().split('/'),
(...paths: string[]) => Strings.normalizePath(path.join(...paths)),
(...parts: string[]) => Strings.normalizePath(paths.join(...parts)),
this.view.config.files.compact
);

+ 2
- 2
src/views/nodes/fileHistoryTrackerNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Disposable, TextEditor, TreeItem, TreeItemCollapsibleState, Uri, window } from 'vscode';
import { UriComparer } from '../../comparers';
import { Container } from '../../container';
@ -87,7 +87,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
);
if (fileName !== undefined) {
uri = Uri.file(repoPath !== undefined ? path.join(repoPath, fileName) : fileName);
uri = Uri.file(repoPath !== undefined ? paths.join(repoPath, fileName) : fileName);
}
}

+ 4
- 4
src/views/nodes/resultsFileNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Command, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Commands, DiffWithCommandArgs } from '../../commands';
import { Container } from '../../container';
@ -30,8 +30,8 @@ export class ResultsFileNode extends ViewNode {
const statusIcon = GitFile.getStatusIcon(this.file.status);
item.iconPath = {
dark: Container.context.asAbsolutePath(path.join('images', 'dark', statusIcon)),
light: Container.context.asAbsolutePath(path.join('images', 'light', statusIcon))
dark: Container.context.asAbsolutePath(paths.join('images', 'dark', statusIcon)),
light: Container.context.asAbsolutePath(paths.join('images', 'light', statusIcon))
};
item.command = this.getCommand();
@ -41,7 +41,7 @@ export class ResultsFileNode extends ViewNode {
private _folderName: string | undefined;
get folderName() {
if (this._folderName === undefined) {
this._folderName = path.dirname(this.uri.getRelativePath());
this._folderName = paths.dirname(this.uri.getRelativePath());
}
return this._folderName;
}

+ 2
- 2
src/views/nodes/resultsFilesNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ViewFilesLayout } from '../../configuration';
import { Container } from '../../container';
@ -38,7 +38,7 @@ export class ResultsFilesNode extends ViewNode {
const hierarchy = Arrays.makeHierarchical(
children,
n => n.uri.getRelativePath().split('/'),
(...paths: string[]) => Strings.normalizePath(path.join(...paths)),
(...parts: string[]) => Strings.normalizePath(paths.join(...parts)),
this.view.config.files.compact
);

+ 6
- 6
src/views/nodes/statusFileNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { Command, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import { Commands, DiffWithPreviousCommandArgs } from '../../commands';
import { Container } from '../../container';
@ -77,7 +77,7 @@ export class StatusFileNode extends ViewNode {
}
// Use the file icon and decorations
item.resourceUri = Uri.file(path.resolve(this.repoPath, this.file.fileName));
item.resourceUri = Uri.file(paths.resolve(this.repoPath, this.file.fileName));
item.iconPath = ThemeIcon.File;
item.command = this.getCommand();
@ -96,7 +96,7 @@ export class StatusFileNode extends ViewNode {
}
// Use the file icon and decorations
item.resourceUri = Uri.file(path.resolve(this.repoPath, this.file.fileName));
item.resourceUri = Uri.file(paths.resolve(this.repoPath, this.file.fileName));
item.iconPath = ThemeIcon.File;
}
else {
@ -104,8 +104,8 @@ export class StatusFileNode extends ViewNode {
const icon = GitFile.getStatusIcon(this.file.status);
item.iconPath = {
dark: Container.context.asAbsolutePath(path.join('images', 'dark', icon)),
light: Container.context.asAbsolutePath(path.join('images', 'light', icon))
dark: Container.context.asAbsolutePath(paths.join('images', 'dark', icon)),
light: Container.context.asAbsolutePath(paths.join('images', 'light', icon))
};
}
item.tooltip = StatusFileFormatter.fromTemplate(
@ -123,7 +123,7 @@ export class StatusFileNode extends ViewNode {
private _folderName: string | undefined;
get folderName() {
if (this._folderName === undefined) {
this._folderName = path.dirname(this.uri.getRelativePath());
this._folderName = paths.dirname(this.uri.getRelativePath());
}
return this._folderName;
}

+ 2
- 2
src/views/nodes/statusFilesNode.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { ViewFilesLayout } from '../../configuration';
import { Container } from '../../container';
@ -94,7 +94,7 @@ export class StatusFilesNode extends ViewNode {
const hierarchy = Arrays.makeHierarchical(
children,
n => n.uri.getRelativePath().split('/'),
(...paths: string[]) => Strings.normalizePath(path.join(...paths)),
(...parts: string[]) => Strings.normalizePath(paths.join(...parts)),
this.view.config.files.compact
);

+ 2
- 2
src/views/viewCommands.ts View File

@ -1,5 +1,5 @@
'use strict';
import * as path from 'path';
import * as paths from 'path';
import { commands, Disposable, InputBoxOptions, Terminal, TextDocumentShowOptions, Uri, window } from 'vscode';
import {
Commands,
@ -223,7 +223,7 @@ export class ViewCommands implements Disposable {
const uri = toGitLensFSUri(node.ref, node.repoPath);
const gitUri = GitUri.fromRevisionUri(uri);
openWorkspace(uri, `${path.basename(gitUri.repoPath!)} @ ${gitUri.shortSha}`, options);
openWorkspace(uri, `${paths.basename(gitUri.repoPath!)} @ ${gitUri.shortSha}`, options);
void commands.executeCommand(BuiltInCommands.FocusFilesExplorer);
}

Loading…
Cancel
Save