diff --git a/src/commands/closeUnchangedFiles.ts b/src/commands/closeUnchangedFiles.ts index 51a7c5b..c94eace 100644 --- a/src/commands/closeUnchangedFiles.ts +++ b/src/commands/closeUnchangedFiles.ts @@ -22,7 +22,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand { try { if (args.uris === undefined) { const repoPath = await this.git.getRepoPathFromUri(uri); - if (repoPath === undefined) return window.showWarningMessage(`Unable to close unchanged files`); + if (!repoPath) return window.showWarningMessage(`Unable to close unchanged files`); const status = await this.git.getStatusForRepo(repoPath); if (status === undefined) return window.showWarningMessage(`Unable to close unchanged files`); diff --git a/src/commands/diffWithBranch.ts b/src/commands/diffWithBranch.ts index 517eb61..d650ef5 100644 --- a/src/commands/diffWithBranch.ts +++ b/src/commands/diffWithBranch.ts @@ -27,7 +27,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand { args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line); const gitUri = await GitUri.fromUri(uri, this.git); - if (gitUri.repoPath === undefined) return undefined; + if (!gitUri.repoPath) return window.showWarningMessage(`Unable to open branch compare`); const branches = await this.git.getBranches(gitUri.repoPath); const pick = await BranchesQuickPick.show(branches, `Compare ${path.basename(gitUri.fsPath)} to \u2026`, args.goBackCommand); @@ -52,7 +52,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand { } catch (ex) { Logger.error(ex, 'DiffWithBranchCommand', 'getVersionedFile'); - return window.showErrorMessage(`Unable to open compare. See output channel for more details`); + return window.showErrorMessage(`Unable to open branch compare. See output channel for more details`); } } } \ No newline at end of file diff --git a/src/commands/openChangedFiles.ts b/src/commands/openChangedFiles.ts index de8cd75..164a971 100644 --- a/src/commands/openChangedFiles.ts +++ b/src/commands/openChangedFiles.ts @@ -20,7 +20,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand { try { if (args.uris === undefined) { const repoPath = await this.git.getRepoPathFromUri(uri); - if (repoPath === undefined) return window.showWarningMessage(`Unable to open changed files`); + if (!repoPath) return window.showWarningMessage(`Unable to open changed files`); const status = await this.git.getStatusForRepo(repoPath); if (status === undefined) return window.showWarningMessage(`Unable to open changed files`); diff --git a/src/commands/showCommitSearch.ts b/src/commands/showCommitSearch.ts index c8a2d85..2b257f8 100644 --- a/src/commands/showCommitSearch.ts +++ b/src/commands/showCommitSearch.ts @@ -29,10 +29,11 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { async execute(editor: TextEditor, uri?: Uri, args: ShowCommitSearchCommandArgs = {}) { uri = getCommandUri(uri, editor); - if (uri === undefined) return undefined; - const gitUri = await GitUri.fromUri(uri, this.git); - if (gitUri.repoPath === undefined) return undefined; + const gitUri = uri === undefined ? undefined : await GitUri.fromUri(uri, this.git); + + const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath; + if (!repoPath) return window.showWarningMessage(`Unable to show commit search`); if (!args.search || args.searchBy == null) { if (!args.search) { @@ -40,6 +41,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { paste((err: Error, content: string) => resolve(err ? '' : content)); }); } + args.search = await window.showInputBox({ value: args.search, prompt: `Please enter a search string`, @@ -65,7 +67,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { args.searchBy = GitRepoSearchBy.Message; } - const log = await this.git.getLogForRepoSearch(gitUri.repoPath, args.search, args.searchBy); + const log = await this.git.getLogForRepoSearch(repoPath, args.search, args.searchBy); if (log === undefined) return undefined; let originalSearch: string | undefined = undefined; @@ -94,7 +96,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { label: `go back \u21A9`, description: `\u00a0 \u2014 \u00a0\u00a0 to commit search` }, Commands.ShowCommitSearch, [ - gitUri, + uri, { search: originalSearch, goBackCommand: args.goBackCommand @@ -115,7 +117,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { label: `go back \u21A9`, description: `\u00a0 \u2014 \u00a0\u00a0 to search for ${placeHolder}` }, Commands.ShowCommitSearch, [ - gitUri, + uri, args ]) } as ShowQuickCommitDetailsCommandArgs); diff --git a/src/commands/showQuickBranchHistory.ts b/src/commands/showQuickBranchHistory.ts index 717f9b2..0f2d9e9 100644 --- a/src/commands/showQuickBranchHistory.ts +++ b/src/commands/showQuickBranchHistory.ts @@ -32,8 +32,8 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand { let progressCancellation = args.branch === undefined ? undefined : BranchHistoryQuickPick.showProgress(args.branch); try { - const repoPath = (gitUri && gitUri.repoPath) || this.git.repoPath; - if (repoPath === undefined) return window.showWarningMessage(`Unable to show branch history`); + const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath; + if (!repoPath) return window.showWarningMessage(`Unable to show branch history`); if (args.branch === undefined) { const branches = await this.git.getBranches(repoPath); diff --git a/src/git/gitUri.ts b/src/git/gitUri.ts index f815596..9bcccf2 100644 --- a/src/git/gitUri.ts +++ b/src/git/gitUri.ts @@ -43,9 +43,12 @@ export class GitUri extends Uri { const commit = commitOrRepoPath; base._fsPath = path.resolve(commit.repoPath, commit.originalFileName || commit.fileName); + if (commit.repoPath !== undefined) { + this.repoPath = commit.repoPath; + } + if (commit.sha !== undefined && !GitService.isUncommitted(commit.sha)) { this.sha = commit.sha; - this.repoPath = commit.repoPath; } } }