mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-14 01:25:43 -05:00
Fixes issues with missing repoPath
Allows commit search without an active editor
This commit is contained in:
@@ -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`);
|
||||
|
||||
@@ -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`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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`);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user