From 7f06da0e2df2dcf779a8de12b40be1637c7d1a17 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 24 Oct 2020 00:36:42 -0400 Subject: [PATCH] Renames isCommandContext* commands --- src/commands/common.ts | 83 ++++++++++++++++----------------- src/commands/copyMessageToClipboard.ts | 4 +- src/commands/copyShaToClipboard.ts | 12 ++--- src/commands/externalDiff.ts | 8 ++-- src/commands/inviteToLiveShare.ts | 4 +- src/commands/openBranchOnRemote.ts | 4 +- src/commands/openBranchesOnRemote.ts | 4 +- src/commands/openCommitOnRemote.ts | 4 +- src/commands/openDirectoryCompare.ts | 4 +- src/commands/openFileOnRemote.ts | 8 ++-- src/commands/openPullRequestOnRemote.ts | 6 +-- src/commands/openRepoOnRemote.ts | 4 +- src/commands/remoteProviders.ts | 6 +-- src/commands/searchCommits.ts | 4 +- src/commands/showQuickCommit.ts | 4 +- src/commands/showQuickCommitFile.ts | 4 +- src/commands/stashApply.ts | 8 ++-- src/commands/stashSave.ts | 14 +++--- 18 files changed, 92 insertions(+), 93 deletions(-) diff --git a/src/commands/common.ts b/src/commands/common.ts index 6deea8d..3d69d8d 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -216,82 +216,82 @@ export interface CommandBaseContext { } export interface CommandScmGroupsContext extends CommandBaseContext { - type: 'scm-groups'; - scmResourceGroups: SourceControlResourceGroup[]; + readonly type: 'scm-groups'; + readonly scmResourceGroups: SourceControlResourceGroup[]; } export interface CommandScmStatesContext extends CommandBaseContext { - type: 'scm-states'; - scmResourceStates: SourceControlResourceState[]; + readonly type: 'scm-states'; + readonly scmResourceStates: SourceControlResourceState[]; } export interface CommandUnknownContext extends CommandBaseContext { - type: 'unknown'; + readonly type: 'unknown'; } export interface CommandUriContext extends CommandBaseContext { - type: 'uri'; + readonly type: 'uri'; } export interface CommandUrisContext extends CommandBaseContext { - type: 'uris'; - uris: Uri[]; + readonly type: 'uris'; + readonly uris: Uri[]; } // export interface CommandViewContext extends CommandBaseContext { -// type: 'view'; +// readonly type: 'view'; // } -export interface CommandViewItemContext extends CommandBaseContext { - type: 'viewItem'; - node: ViewNode; +export interface CommandViewNodeContext extends CommandBaseContext { + readonly type: 'viewItem'; + readonly node: ViewNode; } -export function isCommandViewContextWithBranch( +export function isCommandContextViewNodeHasBranch( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { branch: GitBranch } } { +): context is CommandViewNodeContext & { node: ViewNode & { branch: GitBranch } } { if (context.type !== 'viewItem') return false; return GitBranch.is((context.node as ViewNode & { branch: GitBranch }).branch); } -export function isCommandViewContextWithCommit( +export function isCommandContextViewNodeHasCommit( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { commit: T } } { +): context is CommandViewNodeContext & { node: ViewNode & { commit: T } } { if (context.type !== 'viewItem') return false; return GitCommit.is((context.node as ViewNode & { commit: GitCommit }).commit); } -export function isCommandViewContextWithContributor( +export function isCommandContextViewNodeHasContributor( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { contributor: GitContributor } } { +): context is CommandViewNodeContext & { node: ViewNode & { contributor: GitContributor } } { if (context.type !== 'viewItem') return false; return GitContributor.is((context.node as ViewNode & { contributor: GitContributor }).contributor); } -export function isCommandViewContextWithFile( +export function isCommandContextViewNodeHasFile( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { file: GitFile; repoPath: string } } { +): context is CommandViewNodeContext & { node: ViewNode & { file: GitFile; repoPath: string } } { if (context.type !== 'viewItem') return false; const node = context.node as ViewNode & { file: GitFile; repoPath: string }; return node.file != null && (node.file.repoPath != null || node.repoPath != null); } -export function isCommandViewContextWithFileCommit( +export function isCommandContextViewNodeHasFileCommit( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { commit: GitCommit; file: GitFile; repoPath: string } } { +): context is CommandViewNodeContext & { node: ViewNode & { commit: GitCommit; file: GitFile; repoPath: string } } { if (context.type !== 'viewItem') return false; const node = context.node as ViewNode & { commit: GitCommit; file: GitFile; repoPath: string }; return node.file != null && GitCommit.is(node.commit) && (node.file.repoPath != null || node.repoPath != null); } -export function isCommandViewContextWithFileRefs( +export function isCommandContextViewNodeHasFileRefs( context: CommandContext, -): context is CommandViewItemContext & { +): context is CommandViewNodeContext & { node: ViewNode & { file: GitFile; ref1: string; ref2: string; repoPath: string }; } { if (context.type !== 'viewItem') return false; @@ -305,39 +305,39 @@ export function isCommandViewContextWithFileRefs( ); } -export function isCommandViewContextWithRef( +export function isCommandContextViewNodeHasRef( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { ref: string } } { +): context is CommandViewNodeContext & { node: ViewNode & { ref: string } } { return context.type === 'viewItem' && context.node instanceof ViewRefNode; } -export function isCommandViewContextWithRemote( +export function isCommandContextViewNodeHasRemote( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { remote: GitRemote } } { +): context is CommandViewNodeContext & { node: ViewNode & { remote: GitRemote } } { if (context.type !== 'viewItem') return false; return GitRemote.is((context.node as ViewNode & { remote: GitRemote }).remote); } -export function isCommandViewContextWithRepo( +export function isCommandContextViewNodeHasRepository( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { repo: Repository } } { +): context is CommandViewNodeContext & { node: ViewNode & { repo: Repository } } { if (context.type !== 'viewItem') return false; return (context.node as ViewNode & { repo?: Repository }).repo instanceof Repository; } -export function isCommandViewContextWithRepoPath( +export function isCommandContextViewNodeHasRepoPath( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { repoPath: string } } { +): context is CommandViewNodeContext & { node: ViewNode & { repoPath: string } } { if (context.type !== 'viewItem') return false; return typeof (context.node as ViewNode & { repoPath?: string }).repoPath === 'string'; } -export function isCommandViewContextWithTag( +export function isCommandContextViewNodeHasTag( context: CommandContext, -): context is CommandViewItemContext & { node: ViewNode & { tag: GitTag } } { +): context is CommandViewNodeContext & { node: ViewNode & { tag: GitTag } } { if (context.type !== 'viewItem') return false; return GitTag.is((context.node as ViewNode & { tag: GitTag }).tag); @@ -350,24 +350,23 @@ export type CommandContext = | CommandUriContext | CommandUrisContext // | CommandViewContext - | CommandViewItemContext; + | CommandViewNodeContext; function isScmResourceGroup(group: any): group is SourceControlResourceGroup { if (group == null) return false; return ( - (group as SourceControl).inputBox == null && (group as SourceControlResourceGroup).id != null && - (group.handle != null || - (group as SourceControlResourceGroup).label != null || - (group as SourceControlResourceGroup).resourceStates != null) + (group as SourceControlResourceGroup).label != null && + (group as SourceControlResourceGroup).resourceStates != null && + Array.isArray((group as SourceControlResourceGroup).resourceStates) ); } -function isScmResourceState(state: any): state is SourceControlResourceState { - if (state == null) return false; +function isScmResourceState(resource: any): resource is SourceControlResourceState { + if (resource == null) return false; - return (state as SourceControlResourceState).resourceUri != null; + return (resource as SourceControlResourceState).resourceUri != null; } export abstract class Command implements Disposable { diff --git a/src/commands/copyMessageToClipboard.ts b/src/commands/copyMessageToClipboard.ts index 0cd6651..34220f2 100644 --- a/src/commands/copyMessageToClipboard.ts +++ b/src/commands/copyMessageToClipboard.ts @@ -11,7 +11,7 @@ import { CommandContext, Commands, getCommandUri, - isCommandViewContextWithCommit, + isCommandContextViewNodeHasCommit, } from './common'; export interface CopyMessageToClipboardCommandArgs { @@ -26,7 +26,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand { } protected preExecute(context: CommandContext, args?: CopyMessageToClipboardCommandArgs) { - if (isCommandViewContextWithCommit(context)) { + if (isCommandContextViewNodeHasCommit(context)) { args = { ...args }; args.sha = context.node.commit.sha; return this.execute(context.editor, context.node.commit.uri, args); diff --git a/src/commands/copyShaToClipboard.ts b/src/commands/copyShaToClipboard.ts index f4549a2..4c00753 100644 --- a/src/commands/copyShaToClipboard.ts +++ b/src/commands/copyShaToClipboard.ts @@ -11,9 +11,9 @@ import { CommandContext, Commands, getCommandUri, - isCommandViewContextWithBranch, - isCommandViewContextWithCommit, - isCommandViewContextWithTag, + isCommandContextViewNodeHasBranch, + isCommandContextViewNodeHasCommit, + isCommandContextViewNodeHasTag, } from './common'; export interface CopyShaToClipboardCommandArgs { @@ -27,15 +27,15 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand { } protected preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs) { - if (isCommandViewContextWithCommit(context)) { + if (isCommandContextViewNodeHasCommit(context)) { args = { ...args }; args.sha = context.node.commit.sha; return this.execute(context.editor, context.node.commit.uri, args); - } else if (isCommandViewContextWithBranch(context)) { + } else if (isCommandContextViewNodeHasBranch(context)) { args = { ...args }; args.sha = context.node.branch.sha; return this.execute(context.editor, context.node.uri, args); - } else if (isCommandViewContextWithTag(context)) { + } else if (isCommandContextViewNodeHasTag(context)) { args = { ...args }; args.sha = context.node.tag.sha; return this.execute(context.editor, context.node.uri, args); diff --git a/src/commands/externalDiff.ts b/src/commands/externalDiff.ts index 9ab5807..e62ecff 100644 --- a/src/commands/externalDiff.ts +++ b/src/commands/externalDiff.ts @@ -6,8 +6,8 @@ import { CommandContext, Commands, getRepoPathOrPrompt, - isCommandViewContextWithFileCommit, - isCommandViewContextWithFileRefs, + isCommandContextViewNodeHasFileCommit, + isCommandContextViewNodeHasFileRefs, } from './common'; import { Container } from '../container'; import { GitRevision } from '../git/git'; @@ -68,7 +68,7 @@ export class ExternalDiffCommand extends Command { protected async preExecute(context: CommandContext, args?: ExternalDiffCommandArgs) { args = { ...args }; - if (isCommandViewContextWithFileCommit(context)) { + if (isCommandContextViewNodeHasFileCommit(context)) { const ref1 = GitRevision.isUncommitted(context.node.commit.previousFileSha) ? '' : context.node.commit.previousFileSha; @@ -86,7 +86,7 @@ export class ExternalDiffCommand extends Command { return this.execute(args); } - if (isCommandViewContextWithFileRefs(context)) { + if (isCommandContextViewNodeHasFileRefs(context)) { args.files = [ { uri: GitUri.fromFile(context.node.file, context.node.file.repoPath ?? context.node.repoPath), diff --git a/src/commands/inviteToLiveShare.ts b/src/commands/inviteToLiveShare.ts index bca91bb..5b32b38 100644 --- a/src/commands/inviteToLiveShare.ts +++ b/src/commands/inviteToLiveShare.ts @@ -1,5 +1,5 @@ 'use strict'; -import { command, Command, CommandContext, Commands, isCommandViewContextWithContributor } from './common'; +import { command, Command, CommandContext, Commands, isCommandContextViewNodeHasContributor } from './common'; import { Container } from '../container'; export interface InviteToLiveShareCommandArgs { @@ -21,7 +21,7 @@ export class InviteToLiveShareCommand extends Command { } protected preExecute(context: CommandContext, args?: InviteToLiveShareCommandArgs) { - if (isCommandViewContextWithContributor(context)) { + if (isCommandContextViewNodeHasContributor(context)) { args = { ...args }; args.email = context.node.contributor.email; return this.execute(args); diff --git a/src/commands/openBranchOnRemote.ts b/src/commands/openBranchOnRemote.ts index 848fe28..71c9ab5 100644 --- a/src/commands/openBranchOnRemote.ts +++ b/src/commands/openBranchOnRemote.ts @@ -8,7 +8,7 @@ import { executeCommand, getCommandUri, getRepoPathOrActiveOrPrompt, - isCommandViewContextWithBranch, + isCommandContextViewNodeHasBranch, } from './common'; import { BranchSorting } from '../configuration'; import { RemoteResourceType } from '../git/git'; @@ -30,7 +30,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand { } protected preExecute(context: CommandContext, args?: OpenBranchOnRemoteCommandArgs) { - if (isCommandViewContextWithBranch(context)) { + if (isCommandContextViewNodeHasBranch(context)) { args = { ...args, branch: context.node.branch.name, diff --git a/src/commands/openBranchesOnRemote.ts b/src/commands/openBranchesOnRemote.ts index f60a6b1..32153c5 100644 --- a/src/commands/openBranchesOnRemote.ts +++ b/src/commands/openBranchesOnRemote.ts @@ -11,7 +11,7 @@ import { executeCommand, getCommandUri, getRepoPathOrActiveOrPrompt, - isCommandViewContextWithRemote, + isCommandContextViewNodeHasRemote, } from './common'; import { OpenOnRemoteCommandArgs } from './openOnRemote'; @@ -27,7 +27,7 @@ export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand { } protected preExecute(context: CommandContext, args?: OpenBranchesOnRemoteCommandArgs) { - if (isCommandViewContextWithRemote(context)) { + if (isCommandContextViewNodeHasRemote(context)) { args = { ...args, remote: context.node.remote.name }; } diff --git a/src/commands/openCommitOnRemote.ts b/src/commands/openCommitOnRemote.ts index f2bcdc1..37f1827 100644 --- a/src/commands/openCommitOnRemote.ts +++ b/src/commands/openCommitOnRemote.ts @@ -7,7 +7,7 @@ import { Commands, executeCommand, getCommandUri, - isCommandViewContextWithCommit, + isCommandContextViewNodeHasCommit, } from './common'; import { Container } from '../container'; import { RemoteResourceType } from '../git/git'; @@ -37,7 +37,7 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand { protected preExecute(context: CommandContext, args?: OpenCommitOnRemoteCommandArgs) { let uri = context.uri; - if (isCommandViewContextWithCommit(context)) { + if (isCommandContextViewNodeHasCommit(context)) { if (context.node.commit.isUncommitted) return Promise.resolve(undefined); args = { ...args, sha: context.node.commit.sha }; diff --git a/src/commands/openDirectoryCompare.ts b/src/commands/openDirectoryCompare.ts index d7fbde7..e809c58 100644 --- a/src/commands/openDirectoryCompare.ts +++ b/src/commands/openDirectoryCompare.ts @@ -7,7 +7,7 @@ import { Commands, getCommandUri, getRepoPathOrActiveOrPrompt, - isCommandViewContextWithRef, + isCommandContextViewNodeHasRef, } from './common'; import { Container } from '../container'; import { Logger } from '../logger'; @@ -47,7 +47,7 @@ export class OpenDirectoryCompareCommand extends ActiveEditorCommand { break; case Commands.ViewsOpenDirectoryDiffWithWorking: - if (isCommandViewContextWithRef(context)) { + if (isCommandContextViewNodeHasRef(context)) { args = { ...args }; args.ref1 = context.node.ref; args.ref2 = undefined; diff --git a/src/commands/openFileOnRemote.ts b/src/commands/openFileOnRemote.ts index cd70be4..0d9ce20 100644 --- a/src/commands/openFileOnRemote.ts +++ b/src/commands/openFileOnRemote.ts @@ -7,8 +7,8 @@ import { Commands, executeCommand, getCommandUri, - isCommandViewContextWithBranch, - isCommandViewContextWithCommit, + isCommandContextViewNodeHasBranch, + isCommandContextViewNodeHasCommit, } from './common'; import { UriComparer } from '../comparers'; import { BranchSorting } from '../configuration'; @@ -40,13 +40,13 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand { if (context.type === 'uris' || context.type === 'scm-states') { args = { ...args, range: false }; - } else if (isCommandViewContextWithCommit(context)) { + } else if (isCommandContextViewNodeHasCommit(context)) { args = { ...args, range: false }; if (context.command === Commands.CopyRemoteFileUrl) { // If it is a StatusFileNode then don't include the sha, since it hasn't been pushed yet args.sha = context.node instanceof StatusFileNode ? undefined : context.node.commit.sha; - } else if (isCommandViewContextWithBranch(context)) { + } else if (isCommandContextViewNodeHasBranch(context)) { args.branch = context.node.branch?.name; } diff --git a/src/commands/openPullRequestOnRemote.ts b/src/commands/openPullRequestOnRemote.ts index 6145782..05f81ef 100644 --- a/src/commands/openPullRequestOnRemote.ts +++ b/src/commands/openPullRequestOnRemote.ts @@ -5,8 +5,8 @@ import { command, CommandContext, Commands, - isCommandViewContextWithCommit, - isCommandViewContextWithFileCommit, + isCommandContextViewNodeHasCommit, + isCommandContextViewNodeHasFileCommit, } from './common'; import { Container } from '../container'; import { PullRequestNode } from '../views/nodes/pullRequestNode'; @@ -31,7 +31,7 @@ export class OpenPullRequestOnRemoteCommand extends Command { pr: { url: context.node.pullRequest.url }, }; } - } else if (isCommandViewContextWithCommit(context) || isCommandViewContextWithFileCommit(context)) { + } else if (isCommandContextViewNodeHasCommit(context) || isCommandContextViewNodeHasFileCommit(context)) { args = { ...args, ref: context.node.commit.sha, repoPath: context.node.commit.repoPath }; } diff --git a/src/commands/openRepoOnRemote.ts b/src/commands/openRepoOnRemote.ts index d818291..c517d55 100644 --- a/src/commands/openRepoOnRemote.ts +++ b/src/commands/openRepoOnRemote.ts @@ -8,7 +8,7 @@ import { executeCommand, getCommandUri, getRepoPathOrActiveOrPrompt, - isCommandViewContextWithRemote, + isCommandContextViewNodeHasRemote, } from './common'; import { RemoteResourceType } from '../git/git'; import { GitUri } from '../git/gitUri'; @@ -27,7 +27,7 @@ export class OpenRepoOnRemoteCommand extends ActiveEditorCommand { } protected preExecute(context: CommandContext, args?: OpenRepoOnRemoteCommandArgs) { - if (isCommandViewContextWithRemote(context)) { + if (isCommandContextViewNodeHasRemote(context)) { args = { ...args, remote: context.node.remote.name }; } diff --git a/src/commands/remoteProviders.ts b/src/commands/remoteProviders.ts index 7a0a2a7..c1420d7 100644 --- a/src/commands/remoteProviders.ts +++ b/src/commands/remoteProviders.ts @@ -1,6 +1,6 @@ 'use strict'; import { GitCommit, GitRemote } from '../git/git'; -import { command, Command, CommandContext, Commands, isCommandViewContextWithRemote } from './common'; +import { command, Command, CommandContext, Commands, isCommandContextViewNodeHasRemote } from './common'; import { Container } from '../container'; export interface ConnectRemoteProviderCommandArgs { @@ -31,7 +31,7 @@ export class ConnectRemoteProviderCommand extends Command { } protected preExecute(context: CommandContext, args?: ConnectRemoteProviderCommandArgs) { - if (isCommandViewContextWithRemote(context)) { + if (isCommandContextViewNodeHasRemote(context)) { args = { ...args, remote: context.node.remote.id, repoPath: context.node.remote.repoPath }; } @@ -84,7 +84,7 @@ export class DisconnectRemoteProviderCommand extends Command { } protected preExecute(context: CommandContext, args?: ConnectRemoteProviderCommandArgs) { - if (isCommandViewContextWithRemote(context)) { + if (isCommandContextViewNodeHasRemote(context)) { args = { ...args, remote: context.node.remote.id, repoPath: context.node.remote.repoPath }; } diff --git a/src/commands/searchCommits.ts b/src/commands/searchCommits.ts index d19371e..c6ff127 100644 --- a/src/commands/searchCommits.ts +++ b/src/commands/searchCommits.ts @@ -1,6 +1,6 @@ 'use strict'; import { executeGitCommand } from '../commands'; -import { Command, command, CommandContext, Commands, isCommandViewContextWithRepo } from './common'; +import { Command, command, CommandContext, Commands, isCommandContextViewNodeHasRepository } from './common'; import { Container } from '../container'; import { SearchPattern } from '../git/git'; import { SearchResultsNode } from '../views/nodes'; @@ -31,7 +31,7 @@ export class SearchCommitsCommand extends Command { args.prefillOnly = true; } - if (isCommandViewContextWithRepo(context)) { + if (isCommandContextViewNodeHasRepository(context)) { args.repoPath = context.node.repo.path; } } else if (context.command === Commands.SearchCommitsInView) { diff --git a/src/commands/showQuickCommit.ts b/src/commands/showQuickCommit.ts index d9ce81d..6ced37b 100644 --- a/src/commands/showQuickCommit.ts +++ b/src/commands/showQuickCommit.ts @@ -6,7 +6,7 @@ import { CommandContext, Commands, getCommandUri, - isCommandViewContextWithCommit, + isCommandContextViewNodeHasCommit, } from './common'; import { Container } from '../container'; import { GitCommit, GitLog, GitLogCommit } from '../git/git'; @@ -46,7 +46,7 @@ export class ShowQuickCommitCommand extends ActiveEditorCachedCommand { args = { ...args }; args.sha = context.node.uri.sha; - if (isCommandViewContextWithCommit(context)) { + if (isCommandContextViewNodeHasCommit(context)) { args.commit = context.node.commit; } } diff --git a/src/commands/showQuickCommitFile.ts b/src/commands/showQuickCommitFile.ts index 0f4b44a..d47812e 100644 --- a/src/commands/showQuickCommitFile.ts +++ b/src/commands/showQuickCommitFile.ts @@ -6,7 +6,7 @@ import { CommandContext, Commands, getCommandUri, - isCommandViewContextWithCommit, + isCommandContextViewNodeHasCommit, } from './common'; import { Container } from '../container'; import { GitBlameCommit, GitCommit, GitLog, GitLogCommit } from '../git/git'; @@ -49,7 +49,7 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand { args = { ...args }; args.sha = context.node.uri.sha; - if (isCommandViewContextWithCommit(context)) { + if (isCommandContextViewNodeHasCommit(context)) { args.commit = context.node.commit; } } diff --git a/src/commands/stashApply.ts b/src/commands/stashApply.ts index 3e6dd4d..50dca2a 100644 --- a/src/commands/stashApply.ts +++ b/src/commands/stashApply.ts @@ -5,8 +5,8 @@ import { Command, CommandContext, Commands, - isCommandViewContextWithCommit, - isCommandViewContextWithRepo, + isCommandContextViewNodeHasCommit, + isCommandContextViewNodeHasRepository, } from './common'; import { GitStashCommit, GitStashReference } from '../git/git'; import { CommandQuickPickItem } from '../quickpicks'; @@ -26,9 +26,9 @@ export class StashApplyCommand extends Command { } protected preExecute(context: CommandContext, args?: StashApplyCommandArgs) { - if (isCommandViewContextWithCommit(context)) { + if (isCommandContextViewNodeHasCommit(context)) { args = { ...args, stashItem: context.node.commit }; - } else if (isCommandViewContextWithRepo(context)) { + } else if (isCommandContextViewNodeHasRepository(context)) { args = { ...args, repoPath: context.node.repo.path }; } diff --git a/src/commands/stashSave.ts b/src/commands/stashSave.ts index f7a6ad1..e316b3a 100644 --- a/src/commands/stashSave.ts +++ b/src/commands/stashSave.ts @@ -2,13 +2,13 @@ import { Uri } from 'vscode'; import { GitActions } from '../commands'; import { - command, Command, + command, CommandContext, Commands, - isCommandViewContextWithFile, - isCommandViewContextWithRepo, - isCommandViewContextWithRepoPath, + isCommandContextViewNodeHasFile, + isCommandContextViewNodeHasRepoPath, + isCommandContextViewNodeHasRepository, } from './common'; import { Container } from '../container'; import { GitUri } from '../git/gitUri'; @@ -33,14 +33,14 @@ export class StashSaveCommand extends Command { } protected async preExecute(context: CommandContext, args?: StashSaveCommandArgs) { - if (isCommandViewContextWithFile(context)) { + if (isCommandContextViewNodeHasFile(context)) { args = { ...args }; args.repoPath = context.node.file.repoPath ?? context.node.repoPath; args.uris = [GitUri.fromFile(context.node.file, args.repoPath)]; - } else if (isCommandViewContextWithRepo(context)) { + } else if (isCommandContextViewNodeHasRepository(context)) { args = { ...args }; args.repoPath = context.node.repo.path; - } else if (isCommandViewContextWithRepoPath(context)) { + } else if (isCommandContextViewNodeHasRepoPath(context)) { args = { ...args }; args.repoPath = context.node.repoPath; } else if (context.type === 'scm-states') {