Browse Source

Adds protection for null args in menu callbacks

main
Eric Amodio 5 years ago
parent
commit
577b47fc4a
36 changed files with 102 additions and 87 deletions
  1. +5
    -3
      src/commands/annotations.ts
  2. +2
    -3
      src/commands/closeUnchangedFiles.ts
  3. +3
    -4
      src/commands/copyMessageToClipboard.ts
  4. +3
    -4
      src/commands/copyShaToClipboard.ts
  5. +7
    -4
      src/commands/diffBranchWith.ts
  6. +6
    -4
      src/commands/diffDirectory.ts
  7. +1
    -1
      src/commands/diffLineWithPrevious.ts
  8. +1
    -1
      src/commands/diffLineWithWorking.ts
  9. +3
    -2
      src/commands/diffWithNext.ts
  10. +3
    -2
      src/commands/diffWithPrevious.ts
  11. +1
    -1
      src/commands/diffWithRef.ts
  12. +1
    -1
      src/commands/diffWithRevision.ts
  13. +1
    -1
      src/commands/diffWithWorking.ts
  14. +1
    -1
      src/commands/exploreRepoAtRevision.ts
  15. +6
    -8
      src/commands/externalDiff.ts
  16. +3
    -3
      src/commands/inviteToLiveShare.ts
  17. +4
    -4
      src/commands/openBranchInRemote.ts
  18. +3
    -3
      src/commands/openBranchesInRemote.ts
  19. +2
    -3
      src/commands/openChangedFiles.ts
  20. +5
    -2
      src/commands/openCommitInRemote.ts
  21. +1
    -1
      src/commands/openFileRevision.ts
  22. +3
    -1
      src/commands/openFileRevisionFrom.ts
  23. +2
    -2
      src/commands/openInRemote.ts
  24. +3
    -3
      src/commands/openRepoInRemote.ts
  25. +1
    -1
      src/commands/openRevisionFile.ts
  26. +1
    -1
      src/commands/openWorkingFile.ts
  27. +4
    -2
      src/commands/searchCommits.ts
  28. +1
    -1
      src/commands/showQuickBranchHistory.ts
  29. +2
    -2
      src/commands/showQuickCommitDetails.ts
  30. +4
    -3
      src/commands/showQuickCommitFileDetails.ts
  31. +2
    -2
      src/commands/showQuickCurrentBranchHistory.ts
  32. +4
    -4
      src/commands/showQuickFileHistory.ts
  33. +2
    -2
      src/commands/showQuickRepoStatus.ts
  34. +3
    -3
      src/commands/showQuickStashList.ts
  35. +4
    -2
      src/commands/stashDelete.ts
  36. +4
    -2
      src/commands/stashSave.ts

+ 5
- 3
src/commands/annotations.ts View File

@ -46,7 +46,9 @@ export class ToggleFileBlameCommand extends ActiveEditorCommand {
super(Commands.ToggleFileBlame);
}
execute(editor: TextEditor, uri?: Uri, args: ToggleFileBlameCommandArgs = {}): Thenable<any> {
execute(editor: TextEditor, uri?: Uri, args?: ToggleFileBlameCommandArgs): Thenable<any> {
args = { ...args };
// Handle the case where we are focused on a non-editor editor (output, debug console)
if (editor != null && !isTextEditor(editor)) {
if (uri != null && !UriComparer.equals(uri, editor.document.uri)) {
@ -83,7 +85,7 @@ export class ToggleFileHeatmapCommand extends ActiveEditorCommand {
super(Commands.ToggleFileHeatmap);
}
execute(editor: TextEditor, uri?: Uri, args: ToggleFileBlameCommandArgs = {}): Thenable<any> {
execute(editor: TextEditor, uri?: Uri, args?: ToggleFileBlameCommandArgs): Thenable<any> {
const copyArgs: ToggleFileBlameCommandArgs = {
...args,
type: FileAnnotationType.Heatmap
@ -98,7 +100,7 @@ export class ToggleFileRecentChangesCommand extends ActiveEditorCommand {
super(Commands.ToggleFileRecentChanges);
}
execute(editor: TextEditor, uri?: Uri, args: ToggleFileBlameCommandArgs = {}): Thenable<any> {
execute(editor: TextEditor, uri?: Uri, args?: ToggleFileBlameCommandArgs): Thenable<any> {
const copyArgs: ToggleFileBlameCommandArgs = {
...args,
type: FileAnnotationType.RecentChanges

+ 2
- 3
src/commands/closeUnchangedFiles.ts View File

@ -20,13 +20,12 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
super(Commands.CloseUnchangedFiles);
}
async execute(editor?: TextEditor, uri?: Uri, args: CloseUnchangedFilesCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: CloseUnchangedFilesCommandArgs) {
uri = getCommandUri(uri, editor);
args = { ...args };
try {
if (args.uris === undefined) {
args = { ...args };
const repoPath = await getRepoPathOrPrompt(
`Close all files except those changed in which repository${GlyphChars.Ellipsis}`
);

+ 3
- 4
src/commands/copyMessageToClipboard.ts View File

@ -25,7 +25,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
super(Commands.CopyMessageToClipboard);
}
protected preExecute(context: CommandContext, args: CopyMessageToClipboardCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: CopyMessageToClipboardCommandArgs) {
if (isCommandViewContextWithCommit(context)) {
args = { ...args };
args.sha = context.node.commit.sha;
@ -35,12 +35,11 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: CopyMessageToClipboardCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: CopyMessageToClipboardCommandArgs) {
uri = getCommandUri(uri, editor);
args = { ...args };
try {
args = { ...args };
let repoPath;
// If we don't have an editor then get the message of the last commit to the branch
if (uri == null) {

+ 3
- 4
src/commands/copyShaToClipboard.ts View File

@ -24,7 +24,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
super(Commands.CopyShaToClipboard);
}
protected preExecute(context: CommandContext, args: CopyShaToClipboardCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs) {
if (isCommandViewContextWithCommit(context)) {
args = { ...args };
args.sha = context.node.commit.sha;
@ -34,12 +34,11 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: CopyShaToClipboardCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: CopyShaToClipboardCommandArgs) {
uri = getCommandUri(uri, editor);
args = { ...args };
try {
args = { ...args };
// If we don't have an editor then get the sha of the last commit to the branch
if (uri == null) {
const repoPath = await Container.git.getActiveRepoPath(editor);

+ 7
- 4
src/commands/diffBranchWith.ts View File

@ -30,15 +30,17 @@ export class DiffBranchWithCommand extends ActiveEditorCommand {
]);
}
protected preExecute(context: CommandContext, args: DiffBranchWithCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: DiffBranchWithCommandArgs) {
switch (context.command) {
case Commands.DiffHeadWith:
case Commands.DiffHeadWithBranch:
args = { ...args };
args.ref1 = 'HEAD';
break;
case Commands.DiffWorkingWith:
case Commands.DiffWorkingWithBranch:
args = { ...args };
args.ref1 = '';
break;
}
@ -46,10 +48,11 @@ export class DiffBranchWithCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffBranchWithCommandArgs = {}) {
if (args.ref1 === undefined) return undefined;
async execute(editor?: TextEditor, uri?: Uri, args?: DiffBranchWithCommandArgs) {
uri = getCommandUri(uri, editor);
args = { ...args };
if (args.ref1 === undefined) return undefined;
try {
const repoPath = await getRepoPathOrActiveOrPrompt(

+ 6
- 4
src/commands/diffDirectory.ts View File

@ -32,21 +32,24 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
]);
}
protected async preExecute(context: CommandContext, args: DiffDirectoryCommandArgs = {}) {
protected async preExecute(context: CommandContext, args?: DiffDirectoryCommandArgs) {
switch (context.command) {
case Commands.DiffDirectoryWithHead:
args = { ...args };
args.ref1 = 'HEAD';
args.ref2 = undefined;
break;
case Commands.ViewsOpenDirectoryDiff:
if (context.type === 'viewItem' && context.node instanceof CompareResultsNode) {
args = { ...args };
[args.ref1, args.ref2] = await context.node.getDiffRefs();
}
break;
case Commands.ViewsOpenDirectoryDiffWithWorking:
if (isCommandViewContextWithRef(context)) {
args = { ...args };
args.ref1 = context.node.ref;
args.ref2 = undefined;
}
@ -56,8 +59,9 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffDirectoryCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: DiffDirectoryCommandArgs) {
uri = getCommandUri(uri, editor);
args = { ...args };
try {
const repoPath = await getRepoPathOrActiveOrPrompt(
@ -68,8 +72,6 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
if (!repoPath) return undefined;
if (!args.ref1) {
args = { ...args };
const pick = await new ReferencesQuickPick(repoPath).show(
`Compare Working Tree with${GlyphChars.Ellipsis}`,
{ allowEnteringRefs: true, checkmarks: false }

+ 1
- 1
src/commands/diffLineWithPrevious.ts View File

@ -20,7 +20,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
super(Commands.DiffLineWithPrevious);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffLineWithPreviousCommandArgs = {}): Promise<any> {
async execute(editor?: TextEditor, uri?: Uri, args?: DiffLineWithPreviousCommandArgs): Promise<any> {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;

+ 1
- 1
src/commands/diffLineWithWorking.ts View File

@ -20,7 +20,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
super(Commands.DiffLineWithWorking);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffLineWithWorkingCommandArgs = {}): Promise<any> {
async execute(editor?: TextEditor, uri?: Uri, args?: DiffLineWithWorkingCommandArgs): Promise<any> {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;

+ 3
- 2
src/commands/diffWithNext.ts View File

@ -22,15 +22,16 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
super([Commands.DiffWithNext, Commands.DiffWithNextInDiffLeft]);
}
protected preExecute(context: CommandContext, args: DiffWithNextCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: DiffWithNextCommandArgs) {
if (context.command === Commands.DiffWithNextInDiffLeft) {
args = { ...args };
args.inDiffLeftEditor = true;
}
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffWithNextCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithNextCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;

+ 3
- 2
src/commands/diffWithPrevious.ts View File

@ -21,15 +21,16 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
super([Commands.DiffWithPrevious, Commands.DiffWithPreviousInDiffRight]);
}
protected preExecute(context: CommandContext, args: DiffWithPreviousCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: DiffWithPreviousCommandArgs) {
if (context.command === Commands.DiffWithPreviousInDiffRight) {
args = { ...args };
args.inDiffRightEditor = true;
}
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffWithPreviousCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithPreviousCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;

+ 1
- 1
src/commands/diffWithRef.ts View File

@ -23,7 +23,7 @@ export class DiffWithRefCommand extends ActiveEditorCommand {
super([Commands.DiffWithRef, Commands.DiffWithBranch]);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffWithRefCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithRefCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;

+ 1
- 1
src/commands/diffWithRevision.ts View File

@ -25,7 +25,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
super(Commands.DiffWithRevision);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffWithRevisionCommandArgs = {}): Promise<any> {
async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithRevisionCommandArgs): Promise<any> {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;

+ 1
- 1
src/commands/diffWithWorking.ts View File

@ -20,7 +20,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
super(Commands.DiffWithWorking);
}
async execute(editor?: TextEditor, uri?: Uri, args: DiffWithWorkingCommandArgs = {}): Promise<any> {
async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithWorkingCommandArgs): Promise<any> {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;

+ 1
- 1
src/commands/exploreRepoAtRevision.ts View File

@ -18,7 +18,7 @@ export class ExploreRepoAtRevisionCommand extends ActiveEditorCommand {
super(Commands.ExploreRepoAtRevision);
}
async execute(editor: TextEditor, uri?: Uri, args: ExploreRepoAtRevisionCommandArgs = {}) {
async execute(editor: TextEditor, uri?: Uri, args?: ExploreRepoAtRevisionCommandArgs) {
args = { ...args };
try {

+ 6
- 8
src/commands/externalDiff.ts View File

@ -65,10 +65,10 @@ export class ExternalDiffCommand extends Command {
super([Commands.ExternalDiff, Commands.ExternalDiffAll]);
}
protected async preExecute(context: CommandContext, args: ExternalDiffCommandArgs = {}) {
if (isCommandViewContextWithFileCommit(context)) {
args = { ...args };
protected async preExecute(context: CommandContext, args?: ExternalDiffCommandArgs) {
args = { ...args };
if (isCommandViewContextWithFileCommit(context)) {
const ref1 = GitService.isUncommitted(context.node.commit.previousFileSha)
? ''
: context.node.commit.previousFileSha;
@ -87,8 +87,6 @@ export class ExternalDiffCommand extends Command {
}
if (isCommandViewContextWithFileRefs(context)) {
args = { ...args };
args.files = [
{
uri: GitUri.fromFile(context.node.file, context.node.file.repoPath || context.node.repoPath),
@ -103,13 +101,11 @@ export class ExternalDiffCommand extends Command {
if (args.files === undefined) {
if (context.type === 'scm-states') {
args = { ...args };
args.files = context.scmResourceStates.map(r => ({
uri: r.resourceUri,
staged: (r as Resource).resourceGroupType === ResourceGroupType.Index
}));
} else if (context.type === 'scm-groups') {
args = { ...args };
args.files = Arrays.filterMap(context.scmResourceGroups[0].resourceStates, r =>
this.isModified(r)
? {
@ -153,7 +149,9 @@ export class ExternalDiffCommand extends Command {
return status === Status.BOTH_MODIFIED || status === Status.INDEX_MODIFIED || status === Status.MODIFIED;
}
async execute(args: ExternalDiffCommandArgs = {}) {
async execute(args?: ExternalDiffCommandArgs) {
args = { ...args };
try {
let repoPath;
if (args.files === undefined) {

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

@ -20,7 +20,7 @@ export class InviteToLiveShareCommand extends Command {
super(Commands.InviteToLiveShare);
}
protected preExecute(context: CommandContext, args: InviteToLiveShareCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: InviteToLiveShareCommandArgs) {
if (isCommandViewContextWithContributor(context)) {
args = { ...args };
args.email = context.node.contributor.email;
@ -30,8 +30,8 @@ export class InviteToLiveShareCommand extends Command {
return this.execute(args);
}
async execute(args: InviteToLiveShareCommandArgs = {}) {
if (args.email) {
async execute(args?: InviteToLiveShareCommandArgs) {
if (args != null && args.email) {
const contact = await Container.vsls.getContact(args.email);
if (contact != null) {
return contact.invite();

+ 4
- 4
src/commands/openBranchInRemote.ts View File

@ -27,7 +27,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
super(Commands.OpenBranchInRemote);
}
protected preExecute(context: CommandContext, args: OpenBranchInRemoteCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: OpenBranchInRemoteCommandArgs) {
if (isCommandViewContextWithBranch(context)) {
args = { ...args };
args.branch = context.node.branch.name;
@ -37,7 +37,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: OpenBranchInRemoteCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: OpenBranchInRemoteCommandArgs) {
uri = getCommandUri(uri, editor);
const gitUri = uri && (await GitUri.fromUri(uri));
@ -49,10 +49,10 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
);
if (!repoPath) return undefined;
args = { ...args };
try {
if (args.branch === undefined) {
args = { ...args };
const pick = await new ReferencesQuickPick(repoPath).show(
`Open which branch on remote${GlyphChars.Ellipsis}`,
{

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

@ -25,7 +25,7 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
super(Commands.OpenBranchesInRemote);
}
protected preExecute(context: CommandContext, args: OpenBranchesInRemoteCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: OpenBranchesInRemoteCommandArgs) {
if (isCommandViewContextWithRemote(context)) {
args = { ...args };
args.remote = context.node.remote.name;
@ -34,7 +34,7 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: OpenBranchesInRemoteCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: OpenBranchesInRemoteCommandArgs) {
uri = getCommandUri(uri, editor);
const gitUri = uri && (await GitUri.fromUri(uri));
@ -53,7 +53,7 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
resource: {
type: RemoteResourceType.Branches
},
remote: args.remote,
remote: args && args.remote,
remotes: remotes
};
return commands.executeCommand(Commands.OpenInRemote, uri, commandArgs);

+ 2
- 3
src/commands/openChangedFiles.ts View File

@ -17,13 +17,12 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
super(Commands.OpenChangedFiles);
}
async execute(editor?: TextEditor, uri?: Uri, args: OpenChangedFilesCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: OpenChangedFilesCommandArgs) {
uri = getCommandUri(uri, editor);
args = { ...args };
try {
if (args.uris === undefined) {
args = { ...args };
const repoPath = await getRepoPathOrPrompt(
`Open all files changed in which repository${GlyphChars.Ellipsis}`
);

+ 5
- 2
src/commands/openCommitInRemote.ts View File

@ -31,7 +31,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
super(Commands.OpenCommitInRemote);
}
protected preExecute(context: CommandContext, args: OpenCommitInRemoteCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: OpenCommitInRemoteCommandArgs) {
if (isCommandViewContextWithCommit(context)) {
args = { ...args };
args.sha = context.node.commit.sha;
@ -41,12 +41,15 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: OpenCommitInRemoteCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: OpenCommitInRemoteCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;
const gitUri = await GitUri.fromUri(uri);
if (!gitUri.repoPath) return undefined;
args = { ...args };
try {
if (args.sha === undefined) {
const blameline = editor == null ? 0 : editor.selection.active.line;

+ 1
- 1
src/commands/openFileRevision.ts View File

@ -50,7 +50,7 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand {
super(Commands.OpenFileRevision);
}
async execute(editor: TextEditor | undefined, uri?: Uri, args: OpenFileRevisionCommandArgs = {}) {
async execute(editor: TextEditor | undefined, uri?: Uri, args?: OpenFileRevisionCommandArgs) {
args = { ...args };
if (args.line === undefined) {
args.line = editor == null ? 0 : editor.selection.active.line;

+ 3
- 1
src/commands/openFileRevisionFrom.ts View File

@ -19,13 +19,15 @@ export class OpenFileRevisionFromCommand extends ActiveEditorCommand {
super([Commands.OpenFileRevisionFrom, Commands.OpenFileRevisionFromBranch]);
}
async execute(editor: TextEditor | undefined, uri?: Uri, args: OpenFileRevisionFromCommandArgs = {}) {
async execute(editor: TextEditor | undefined, uri?: Uri, args?: OpenFileRevisionFromCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;
const gitUri = await GitUri.fromUri(uri);
if (!gitUri.repoPath) return undefined;
args = { ...args };
if (args.reference === undefined) {
const placeHolder = `Open revision of ${gitUri.getFormattedPath()}${
gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''

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

@ -23,12 +23,12 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
super(Commands.OpenInRemote);
}
async execute(editor: TextEditor, uri?: Uri, args: OpenInRemoteCommandArgs = {}) {
async execute(editor: TextEditor, uri?: Uri, args?: OpenInRemoteCommandArgs) {
args = { ...args };
if (args.remotes === undefined || args.resource === undefined) return undefined;
if (args.remote !== undefined) {
const remotes = args.remotes.filter(r => r.name === args.remote);
const remotes = args.remotes.filter(r => r.name === args!.remote);
// Only filter if we get some results
if (remotes.length > 0) {
args.remotes = remotes;

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

@ -25,7 +25,7 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
super(Commands.OpenRepoInRemote);
}
protected preExecute(context: CommandContext, args: OpenRepoInRemoteCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: OpenRepoInRemoteCommandArgs) {
if (isCommandViewContextWithRemote(context)) {
args = { ...args };
args.remote = context.node.remote.name;
@ -34,7 +34,7 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: OpenRepoInRemoteCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: OpenRepoInRemoteCommandArgs) {
uri = getCommandUri(uri, editor);
const gitUri = uri && (await GitUri.fromUri(uri));
@ -53,7 +53,7 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
resource: {
type: RemoteResourceType.Repo
},
remote: args.remote,
remote: args && args.remote,
remotes: remotes
};
return commands.executeCommand(Commands.OpenInRemote, uri, commandArgs);

+ 1
- 1
src/commands/openRevisionFile.ts View File

@ -20,7 +20,7 @@ export class OpenRevisionFileCommand extends ActiveEditorCommand {
super(Commands.OpenRevisionFile);
}
async execute(editor: TextEditor, uri?: Uri, args: OpenRevisionFileCommandArgs = {}) {
async execute(editor: TextEditor, uri?: Uri, args?: OpenRevisionFileCommandArgs) {
args = { ...args };
if (args.line === undefined) {
args.line = editor == null ? 0 : editor.selection.active.line;

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

@ -20,7 +20,7 @@ export class OpenWorkingFileCommand extends ActiveEditorCommand {
super(Commands.OpenWorkingFile);
}
async execute(editor: TextEditor, uri?: Uri, args: OpenWorkingFileCommandArgs = {}) {
async execute(editor: TextEditor, uri?: Uri, args?: OpenWorkingFileCommandArgs) {
args = { ...args };
if (args.line === undefined) {
args.line = editor == null ? 0 : editor.selection.active.line;

+ 4
- 2
src/commands/searchCommits.ts View File

@ -25,7 +25,7 @@ export class SearchCommitsCommand extends Command {
super([Commands.SearchCommits, Commands.SearchCommitsInView]);
}
protected preExecute(context: CommandContext, args: SearchCommitsCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: SearchCommitsCommandArgs) {
if (context.type === 'viewItem') {
args = { ...args };
args.showInView = true;
@ -47,7 +47,9 @@ export class SearchCommitsCommand extends Command {
return this.execute(args);
}
async execute(args: SearchCommitsCommandArgs = {}) {
async execute(args?: SearchCommitsCommandArgs) {
args = { ...args };
let repo;
if (args.repoPath !== undefined) {
repo = await Container.git.getRepository(args.repoPath);

+ 1
- 1
src/commands/showQuickBranchHistory.ts View File

@ -30,7 +30,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
super(Commands.ShowQuickBranchHistory);
}
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickBranchHistoryCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickBranchHistoryCommandArgs) {
uri = getCommandUri(uri, editor);
const gitUri = uri && (await GitUri.fromUri(uri));

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

@ -41,7 +41,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
super([Commands.ShowCommitInView, Commands.ShowQuickCommitDetails]);
}
protected preExecute(context: CommandContext, args: ShowQuickCommitDetailsCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: ShowQuickCommitDetailsCommandArgs) {
if (context.command === Commands.ShowCommitInView) {
args = { ...args };
args.showInView = true;
@ -59,7 +59,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitDetailsCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickCommitDetailsCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;

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

@ -38,7 +38,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
super([Commands.ShowQuickCommitFileDetails, Commands.ShowQuickRevisionDetails]);
}
protected async preExecute(context: CommandContext, args: ShowQuickCommitFileDetailsCommandArgs = {}) {
protected async preExecute(context: CommandContext, args?: ShowQuickCommitFileDetailsCommandArgs) {
if (context.command === Commands.ShowQuickRevisionDetails && context.editor !== undefined) {
args = { ...args };
@ -58,10 +58,12 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitFileDetailsCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickCommitFileDetailsCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;
args = { ...args };
let gitUri;
if (args.revisionUri !== undefined) {
gitUri = GitUri.fromRevisionUri(Uri.parse(args.revisionUri));
@ -70,7 +72,6 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
gitUri = await GitUri.fromUri(uri);
}
args = { ...args };
if (args.sha === undefined) {
if (editor == null) return undefined;

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

@ -18,7 +18,7 @@ export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedComm
super(Commands.ShowQuickCurrentBranchHistory);
}
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCurrentBranchHistoryCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickCurrentBranchHistoryCommandArgs) {
uri = getCommandUri(uri, editor);
try {
@ -35,7 +35,7 @@ export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedComm
const commandArgs: ShowQuickBranchHistoryCommandArgs = {
branch: branch.name,
repoPath: repoPath,
goBackCommand: args.goBackCommand
goBackCommand: args && args.goBackCommand
};
return commands.executeCommand(Commands.ShowQuickBranchHistory, uri, commandArgs);
} catch (ex) {

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

@ -32,7 +32,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
super([Commands.ShowFileHistoryInView, Commands.ShowQuickFileHistory]);
}
protected preExecute(context: CommandContext, args: ShowQuickFileHistoryCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: ShowQuickFileHistoryCommandArgs) {
if (context.command === Commands.ShowFileHistoryInView) {
args = { ...args };
args.showInView = true;
@ -41,20 +41,20 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
return this.execute(context.editor, context.uri, args);
}
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickFileHistoryCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickFileHistoryCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return commands.executeCommand(Commands.ShowQuickCurrentBranchHistory);
const gitUri = await GitUri.fromUri(uri);
args = { ...args };
if (args.showInView) {
await Container.fileHistoryView.showHistoryForUri(gitUri);
return undefined;
}
args = { ...args };
const placeHolder = `${gitUri.getFormattedPath({
suffix: args.reference ? ` (${args.reference.name})` : undefined
})}${gitUri.sha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${gitUri.shortSha}` : ''}`;

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

@ -17,7 +17,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
super(Commands.ShowQuickRepoStatus);
}
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickRepoStatusCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickRepoStatusCommandArgs) {
uri = getCommandUri(uri, editor);
try {
@ -31,7 +31,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
const status = await Container.git.getStatusForRepo(repoPath);
if (status === undefined) return window.showWarningMessage('Unable to show repository status');
const pick = await RepoStatusQuickPick.show(status, args.goBackCommand);
const pick = await RepoStatusQuickPick.show(status, args && args.goBackCommand);
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();

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

@ -18,7 +18,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
super(Commands.ShowQuickStashList);
}
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickStashListCommandArgs = {}) {
async execute(editor?: TextEditor, uri?: Uri, args?: ShowQuickStashListCommandArgs) {
uri = getCommandUri(uri, editor);
const repoPath = await getRepoPathOrActiveOrPrompt(
@ -38,7 +38,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
// Create a command to get back to here
const currentCommandArgs: ShowQuickStashListCommandArgs = {
goBackCommand: args.goBackCommand
goBackCommand: args && args.goBackCommand
};
const currentCommand = new CommandQuickPickItem(
{
@ -53,7 +53,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
stash,
'list',
progressCancellation,
args.goBackCommand,
args && args.goBackCommand,
currentCommand
);
if (pick === undefined) return undefined;

+ 4
- 2
src/commands/stashDelete.ts View File

@ -19,7 +19,7 @@ export class StashDeleteCommand extends Command {
super(Commands.StashDelete);
}
protected preExecute(context: CommandContext, args: StashDeleteCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: StashDeleteCommandArgs) {
if (isCommandViewContextWithCommit<GitStashCommit>(context)) {
args = { ...args };
args.stashItem = context.node.commit;
@ -28,7 +28,9 @@ export class StashDeleteCommand extends Command {
return this.execute(args);
}
async execute(args: StashDeleteCommandArgs = {}) {
async execute(args?: StashDeleteCommandArgs) {
args = { ...args };
let repo;
if (args.stashItem !== undefined || args.repoPath !== undefined) {
repo = await Container.git.getRepository((args.stashItem && args.stashItem.repoPath) || args.repoPath!);

+ 4
- 2
src/commands/stashSave.ts View File

@ -29,7 +29,7 @@ export class StashSaveCommand extends Command {
super([Commands.StashSave, Commands.StashSaveFiles]);
}
protected preExecute(context: CommandContext, args: StashSaveCommandArgs = {}) {
protected preExecute(context: CommandContext, args?: StashSaveCommandArgs) {
if (isCommandViewContextWithFile(context)) {
args = { ...args };
args.repoPath = context.node.file.repoPath || context.node.repoPath;
@ -59,7 +59,9 @@ export class StashSaveCommand extends Command {
return this.execute(args);
}
async execute(args: StashSaveCommandArgs = {}) {
async execute(args?: StashSaveCommandArgs) {
args = { ...args };
let repo;
if (args.uris !== undefined || args.repoPath !== undefined) {
repo = await Container.git.getRepository((args.uris && args.uris[0]) || args.repoPath!);

Loading…
Cancel
Save