From b2750e965439a5ef09bbed3fed523cbf897d2396 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 28 Oct 2018 00:26:25 -0400 Subject: [PATCH] Fixes relative paths when repoPath is missing Renames path import to paths for less naming conflicts --- src/annotations/fileAnnotationController.ts | 4 ++-- src/commands/common.ts | 4 ++-- src/commands/diffWith.ts | 6 ++--- src/commands/diffWithBranch.ts | 12 +++++----- src/commands/openWorkingFile.ts | 4 ++-- src/commands/showQuickCommitDetails.ts | 6 ++--- src/commands/showQuickCommitFileDetails.ts | 6 ++--- src/commands/showQuickFileHistory.ts | 4 ++-- src/git/formatters/statusFormatter.ts | 4 ++-- src/git/gitUri.ts | 37 ++++++++++++++++------------- src/git/locator.ts | 4 ++-- src/git/models/commit.ts | 8 +++---- src/git/models/logCommit.ts | 6 ++--- src/git/models/status.ts | 4 ++-- src/git/parsers/blameParser.ts | 4 ++-- src/git/parsers/logParser.ts | 4 ++-- src/git/shell.ts | 10 ++++---- src/quickpicks/commitFileQuickPick.ts | 26 ++++++++++---------- src/quickpicks/commitQuickPick.ts | 4 ++-- src/quickpicks/fileHistoryQuickPick.ts | 12 +++++----- src/quickpicks/remotesQuickPick.ts | 10 ++++---- src/quickpicks/repoStatusQuickPick.ts | 4 ++-- src/views/nodes/commitFileNode.ts | 12 +++++----- src/views/nodes/commitNode.ts | 4 ++-- src/views/nodes/fileHistoryTrackerNode.ts | 4 ++-- src/views/nodes/resultsFileNode.ts | 8 +++---- src/views/nodes/resultsFilesNode.ts | 4 ++-- src/views/nodes/statusFileNode.ts | 12 +++++----- src/views/nodes/statusFilesNode.ts | 4 ++-- src/views/viewCommands.ts | 4 ++-- 30 files changed, 119 insertions(+), 116 deletions(-) diff --git a/src/annotations/fileAnnotationController.ts b/src/annotations/fileAnnotationController.ts index 74daae1..d1390bf 100644 --- a/src/annotations/fileAnnotationController.ts +++ b/src/annotations/fileAnnotationController.ts @@ -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)}` }); } diff --git a/src/commands/common.ts b/src/commands/common.ts index 8041c34..2015863 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -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; diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 46639a1..ec72c5d 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -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 = diff --git a/src/commands/diffWithBranch.ts b/src/commands/diffWithBranch.ts index e68b62a..c27083c 100644 --- a/src/commands/diffWithBranch.ts +++ b/src/commands/diffWithBranch.ts @@ -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: '', diff --git a/src/commands/openWorkingFile.ts b/src/commands/openWorkingFile.ts index b0642c3..a510028 100644 --- a/src/commands/openWorkingFile.ts +++ b/src/commands/openWorkingFile.ts @@ -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); } } diff --git a/src/commands/showQuickCommitDetails.ts b/src/commands/showQuickCommitDetails.ts index 51b958f..9273e32 100644 --- a/src/commands/showQuickCommitDetails.ts +++ b/src/commands/showQuickCommitDetails.ts @@ -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) { diff --git a/src/commands/showQuickCommitFileDetails.ts b/src/commands/showQuickCommitFileDetails.ts index cbf2e9a..58c0ce7 100644 --- a/src/commands/showQuickCommitFileDetails.ts +++ b/src/commands/showQuickCommitFileDetails.ts @@ -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}` }, diff --git a/src/commands/showQuickFileHistory.ts b/src/commands/showQuickFileHistory.ts index 179eec3..c3b9674 100644 --- a/src/commands/showQuickFileHistory.ts +++ b/src/commands/showQuickFileHistory.ts @@ -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)' diff --git a/src/git/formatters/statusFormatter.ts b/src/git/formatters/statusFormatter.ts index 57f07ae..c1c9b9b 100644 --- a/src/git/formatters/statusFormatter.ts +++ b/src/git/formatters/statusFormatter.ts @@ -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 { function findSystemGitWin32(basePath: string): Promise { 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 { diff --git a/src/git/models/commit.ts b/src/git/models/commit.ts index cc03d18..77a766f 100644 --- a/src/git/models/commit.ts +++ b/src/git/models/commit.ts @@ -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; diff --git a/src/git/models/logCommit.ts b/src/git/models/logCommit.ts index 8699d57..fb2aa2d 100644 --- a/src/git/models/logCommit.ts +++ b/src/git/models/logCommit.ts @@ -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; } diff --git a/src/git/models/status.ts b/src/git/models/status.ts index cda17ad..da59e36 100644 --- a/src/git/models/status.ts +++ b/src/git/models/status.ts @@ -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 { diff --git a/src/git/parsers/blameParser.ts b/src/git/parsers/blameParser.ts index cf63a53..1a5b7b6 100644 --- a/src/git/parsers/blameParser.ts +++ b/src/git/parsers/blameParser.ts @@ -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; diff --git a/src/git/parsers/logParser.ts b/src/git/parsers/logParser.ts index 1e19900..25c9a94 100644 --- a/src/git/parsers/logParser.ts +++ b/src/git/parsers/logParser.ts @@ -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!; diff --git a/src/git/shell.ts b/src/git/shell.ts index 34951a5..3eaa1eb 100644 --- a/src/git/shell.ts +++ b/src/git/shell.ts @@ -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 }; diff --git a/src/quickpicks/commitFileQuickPick.ts b/src/quickpicks/commitFileQuickPick.ts index 983c73c..18d5bf8 100644 --- a/src/quickpicks/commitFileQuickPick.ts +++ b/src/quickpicks/commitFileQuickPick.ts @@ -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 diff --git a/src/quickpicks/commitQuickPick.ts b/src/quickpicks/commitQuickPick.ts index 0749ca4..5a2d738 100644 --- a/src/quickpicks/commitQuickPick.ts +++ b/src/quickpicks/commitQuickPick.ts @@ -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 }); diff --git a/src/quickpicks/fileHistoryQuickPick.ts b/src/quickpicks/fileHistoryQuickPick.ts index 7afb5e0..75c503f 100644 --- a/src/quickpicks/fileHistoryQuickPick.ts +++ b/src/quickpicks/fileHistoryQuickPick.ts @@ -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}` : '' }` }, diff --git a/src/quickpicks/remotesQuickPick.ts b/src/quickpicks/remotesQuickPick.ts index 658f928..ffecef9 100644 --- a/src/quickpicks/remotesQuickPick.ts +++ b/src/quickpicks/remotesQuickPick.ts @@ -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}` : '' }`; } diff --git a/src/quickpicks/repoStatusQuickPick.ts b/src/quickpicks/repoStatusQuickPick.ts index fe5af84..ddf821d 100644 --- a/src/quickpicks/repoStatusQuickPick.ts +++ b/src/quickpicks/repoStatusQuickPick.ts @@ -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 } ); diff --git a/src/views/nodes/commitFileNode.ts b/src/views/nodes/commitFileNode.ts index c7e4ec5..a52f0b8 100644 --- a/src/views/nodes/commitFileNode.ts +++ b/src/views/nodes/commitFileNode.ts @@ -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; } diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts index 8a00d21..c27f092 100644 --- a/src/views/nodes/commitNode.ts +++ b/src/views/nodes/commitNode.ts @@ -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 ); diff --git a/src/views/nodes/fileHistoryTrackerNode.ts b/src/views/nodes/fileHistoryTrackerNode.ts index c52dd29..c197adf 100644 --- a/src/views/nodes/fileHistoryTrackerNode.ts +++ b/src/views/nodes/fileHistoryTrackerNode.ts @@ -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 n.uri.getRelativePath().split('/'), - (...paths: string[]) => Strings.normalizePath(path.join(...paths)), + (...parts: string[]) => Strings.normalizePath(paths.join(...parts)), this.view.config.files.compact ); diff --git a/src/views/nodes/statusFileNode.ts b/src/views/nodes/statusFileNode.ts index b5b87d1..eef4f32 100644 --- a/src/views/nodes/statusFileNode.ts +++ b/src/views/nodes/statusFileNode.ts @@ -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; } diff --git a/src/views/nodes/statusFilesNode.ts b/src/views/nodes/statusFilesNode.ts index 7e75e9f..ee2a9ed 100644 --- a/src/views/nodes/statusFilesNode.ts +++ b/src/views/nodes/statusFilesNode.ts @@ -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 ); diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index 569548c..6a35654 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -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); }