From ece34dba3246933fb40492461ae175e05290a5b5 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 5 Sep 2017 21:30:07 -0400 Subject: [PATCH] Cleans up some command overrides --- src/commands/openBranchInRemote.ts | 2 -- src/commands/openBranchesInRemote.ts | 1 - src/commands/openRepoInRemote.ts | 1 - src/commands/showQuickCommitDetails.ts | 12 ++++++------ src/commands/showQuickCommitFileDetails.ts | 12 ++++++------ src/commands/stashApply.ts | 2 +- src/commands/stashDelete.ts | 2 +- src/commands/stashSave.ts | 2 +- 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/commands/openBranchInRemote.ts b/src/commands/openBranchInRemote.ts index 0822124..3d65fb8 100644 --- a/src/commands/openBranchInRemote.ts +++ b/src/commands/openBranchInRemote.ts @@ -22,10 +22,8 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand { protected async preExecute(context: CommandContext, args: OpenBranchInRemoteCommandArgs = {}): Promise { if (isCommandViewContextWithBranch(context)) { args = { ...args }; - args.branch = context.node.branch.name; args.remote = context.node.branch.getRemote(); - return this.execute(context.editor, context.uri, args); } return this.execute(context.editor, context.uri, args); diff --git a/src/commands/openBranchesInRemote.ts b/src/commands/openBranchesInRemote.ts index 0b1775b..e79df83 100644 --- a/src/commands/openBranchesInRemote.ts +++ b/src/commands/openBranchesInRemote.ts @@ -20,7 +20,6 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand { if (isCommandViewContextWithRemote(context)) { args = { ...args }; args.remote = context.node.remote.name; - return this.execute(context.editor, context.uri, args); } return this.execute(context.editor, context.uri, args); diff --git a/src/commands/openRepoInRemote.ts b/src/commands/openRepoInRemote.ts index 67a91cb..bf4828f 100644 --- a/src/commands/openRepoInRemote.ts +++ b/src/commands/openRepoInRemote.ts @@ -20,7 +20,6 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand { if (isCommandViewContextWithRemote(context)) { args = { ...args }; args.remote = context.node.remote.name; - return this.execute(context.editor, context.uri, args); } return this.execute(context.editor, context.uri, args); diff --git a/src/commands/showQuickCommitDetails.ts b/src/commands/showQuickCommitDetails.ts index bc2e67f..dc8f683 100644 --- a/src/commands/showQuickCommitDetails.ts +++ b/src/commands/showQuickCommitDetails.ts @@ -24,16 +24,16 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand { super(Commands.ShowQuickCommitDetails); } - protected async preExecute(context: CommandContext, ...args: any[]): Promise { + protected async preExecute(context: CommandContext, args: ShowQuickCommitDetailsCommandArgs = {}): Promise { if (context.type === 'view') { + args = { ...args }; + args.sha = context.node.uri.sha; + if (isCommandViewContextWithCommit(context)) { - args = [{ sha: context.node.uri.sha, commit: context.node.commit }]; - } - else { - args = [{ sha: context.node.uri.sha }]; + args.commit = context.node.commit; } } - return this.execute(context.editor, context.uri, ...args); + return this.execute(context.editor, context.uri, args); } async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitDetailsCommandArgs = {}) { diff --git a/src/commands/showQuickCommitFileDetails.ts b/src/commands/showQuickCommitFileDetails.ts index f2fb799..cd05583 100644 --- a/src/commands/showQuickCommitFileDetails.ts +++ b/src/commands/showQuickCommitFileDetails.ts @@ -24,16 +24,16 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand super(Commands.ShowQuickCommitFileDetails); } - protected async preExecute(context: CommandContext, ...args: any[]): Promise { + protected async preExecute(context: CommandContext, args: ShowQuickCommitFileDetailsCommandArgs = {}): Promise { if (context.type === 'view') { + args = { ...args }; + args.sha = context.node.uri.sha; + if (isCommandViewContextWithCommit(context)) { - args = [{ sha: context.node.uri.sha, commit: context.node.commit }]; - } - else { - args = [{ sha: context.node.uri.sha }]; + args.commit = context.node.commit; } } - return this.execute(context.editor, context.uri, ...args); + return this.execute(context.editor, context.uri, args); } async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitFileDetailsCommandArgs = {}) { diff --git a/src/commands/stashApply.ts b/src/commands/stashApply.ts index 39ce5d8..60ee50c 100644 --- a/src/commands/stashApply.ts +++ b/src/commands/stashApply.ts @@ -28,7 +28,7 @@ export class StashApplyCommand extends Command { return this.execute(args); } - return super.preExecute(context, args); + return this.execute(args); } async execute(args: StashApplyCommandArgs = { confirm: true, deleteAfter: false }) { diff --git a/src/commands/stashDelete.ts b/src/commands/stashDelete.ts index 9d447c3..cd75fca 100644 --- a/src/commands/stashDelete.ts +++ b/src/commands/stashDelete.ts @@ -26,7 +26,7 @@ export class StashDeleteCommand extends Command { return this.execute(args); } - return super.preExecute(context, args); + return this.execute(args); } async execute(args: StashDeleteCommandArgs = { confirm: true }) { diff --git a/src/commands/stashSave.ts b/src/commands/stashSave.ts index 9a0e237..5e5814d 100644 --- a/src/commands/stashSave.ts +++ b/src/commands/stashSave.ts @@ -35,7 +35,7 @@ export class StashSaveCommand extends Command { return this.execute(args); } - async execute(args: StashSaveCommandArgs = { }) { + async execute(args: StashSaveCommandArgs = {}) { if (!this.git.repoPath) return undefined; try {