Quellcode durchsuchen

Renames isCommandContext* commands

main
Eric Amodio vor 4 Jahren
Ursprung
Commit
7f06da0e2d
18 geänderte Dateien mit 92 neuen und 93 gelöschten Zeilen
  1. +41
    -42
      src/commands/common.ts
  2. +2
    -2
      src/commands/copyMessageToClipboard.ts
  3. +6
    -6
      src/commands/copyShaToClipboard.ts
  4. +4
    -4
      src/commands/externalDiff.ts
  5. +2
    -2
      src/commands/inviteToLiveShare.ts
  6. +2
    -2
      src/commands/openBranchOnRemote.ts
  7. +2
    -2
      src/commands/openBranchesOnRemote.ts
  8. +2
    -2
      src/commands/openCommitOnRemote.ts
  9. +2
    -2
      src/commands/openDirectoryCompare.ts
  10. +4
    -4
      src/commands/openFileOnRemote.ts
  11. +3
    -3
      src/commands/openPullRequestOnRemote.ts
  12. +2
    -2
      src/commands/openRepoOnRemote.ts
  13. +3
    -3
      src/commands/remoteProviders.ts
  14. +2
    -2
      src/commands/searchCommits.ts
  15. +2
    -2
      src/commands/showQuickCommit.ts
  16. +2
    -2
      src/commands/showQuickCommitFile.ts
  17. +4
    -4
      src/commands/stashApply.ts
  18. +7
    -7
      src/commands/stashSave.ts

+ 41
- 42
src/commands/common.ts Datei anzeigen

@ -216,82 +216,82 @@ export interface CommandBaseContext {
} }
export interface CommandScmGroupsContext extends CommandBaseContext { export interface CommandScmGroupsContext extends CommandBaseContext {
type: 'scm-groups';
scmResourceGroups: SourceControlResourceGroup[];
readonly type: 'scm-groups';
readonly scmResourceGroups: SourceControlResourceGroup[];
} }
export interface CommandScmStatesContext extends CommandBaseContext { export interface CommandScmStatesContext extends CommandBaseContext {
type: 'scm-states';
scmResourceStates: SourceControlResourceState[];
readonly type: 'scm-states';
readonly scmResourceStates: SourceControlResourceState[];
} }
export interface CommandUnknownContext extends CommandBaseContext { export interface CommandUnknownContext extends CommandBaseContext {
type: 'unknown';
readonly type: 'unknown';
} }
export interface CommandUriContext extends CommandBaseContext { export interface CommandUriContext extends CommandBaseContext {
type: 'uri';
readonly type: 'uri';
} }
export interface CommandUrisContext extends CommandBaseContext { export interface CommandUrisContext extends CommandBaseContext {
type: 'uris';
uris: Uri[];
readonly type: 'uris';
readonly uris: Uri[];
} }
// export interface CommandViewContext extends CommandBaseContext { // 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: CommandContext,
): context is CommandViewItemContext & { node: ViewNode & { branch: GitBranch } } {
): context is CommandViewNodeContext & { node: ViewNode & { branch: GitBranch } } {
if (context.type !== 'viewItem') return false; if (context.type !== 'viewItem') return false;
return GitBranch.is((context.node as ViewNode & { branch: GitBranch }).branch); return GitBranch.is((context.node as ViewNode & { branch: GitBranch }).branch);
} }
export function isCommandViewContextWithCommit<T extends GitCommit>(
export function isCommandContextViewNodeHasCommit<T extends GitCommit>(
context: CommandContext, context: CommandContext,
): context is CommandViewItemContext & { node: ViewNode & { commit: T } } {
): context is CommandViewNodeContext & { node: ViewNode & { commit: T } } {
if (context.type !== 'viewItem') return false; if (context.type !== 'viewItem') return false;
return GitCommit.is((context.node as ViewNode & { commit: GitCommit }).commit); return GitCommit.is((context.node as ViewNode & { commit: GitCommit }).commit);
} }
export function isCommandViewContextWithContributor(
export function isCommandContextViewNodeHasContributor(
context: CommandContext, context: CommandContext,
): context is CommandViewItemContext & { node: ViewNode & { contributor: GitContributor } } {
): context is CommandViewNodeContext & { node: ViewNode & { contributor: GitContributor } } {
if (context.type !== 'viewItem') return false; if (context.type !== 'viewItem') return false;
return GitContributor.is((context.node as ViewNode & { contributor: GitContributor }).contributor); return GitContributor.is((context.node as ViewNode & { contributor: GitContributor }).contributor);
} }
export function isCommandViewContextWithFile(
export function isCommandContextViewNodeHasFile(
context: CommandContext, 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; if (context.type !== 'viewItem') return false;
const node = context.node as ViewNode & { file: GitFile; repoPath: string }; const node = context.node as ViewNode & { file: GitFile; repoPath: string };
return node.file != null && (node.file.repoPath != null || node.repoPath != null); return node.file != null && (node.file.repoPath != null || node.repoPath != null);
} }
export function isCommandViewContextWithFileCommit(
export function isCommandContextViewNodeHasFileCommit(
context: CommandContext, 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; if (context.type !== 'viewItem') return false;
const node = context.node as ViewNode & { commit: GitCommit; file: GitFile; repoPath: string }; 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); return node.file != null && GitCommit.is(node.commit) && (node.file.repoPath != null || node.repoPath != null);
} }
export function isCommandViewContextWithFileRefs(
export function isCommandContextViewNodeHasFileRefs(
context: CommandContext, context: CommandContext,
): context is CommandViewItemContext & {
): context is CommandViewNodeContext & {
node: ViewNode & { file: GitFile; ref1: string; ref2: string; repoPath: string }; node: ViewNode & { file: GitFile; ref1: string; ref2: string; repoPath: string };
} { } {
if (context.type !== 'viewItem') return false; if (context.type !== 'viewItem') return false;
@ -305,39 +305,39 @@ export function isCommandViewContextWithFileRefs(
); );
} }
export function isCommandViewContextWithRef(
export function isCommandContextViewNodeHasRef(
context: CommandContext, context: CommandContext,
): context is CommandViewItemContext & { node: ViewNode & { ref: string } } {
): context is CommandViewNodeContext & { node: ViewNode & { ref: string } } {
return context.type === 'viewItem' && context.node instanceof ViewRefNode; return context.type === 'viewItem' && context.node instanceof ViewRefNode;
} }
export function isCommandViewContextWithRemote(
export function isCommandContextViewNodeHasRemote(
context: CommandContext, context: CommandContext,
): context is CommandViewItemContext & { node: ViewNode & { remote: GitRemote } } {
): context is CommandViewNodeContext & { node: ViewNode & { remote: GitRemote } } {
if (context.type !== 'viewItem') return false; if (context.type !== 'viewItem') return false;
return GitRemote.is((context.node as ViewNode & { remote: GitRemote }).remote); return GitRemote.is((context.node as ViewNode & { remote: GitRemote }).remote);
} }
export function isCommandViewContextWithRepo(
export function isCommandContextViewNodeHasRepository(
context: CommandContext, context: CommandContext,
): context is CommandViewItemContext & { node: ViewNode & { repo: Repository } } {
): context is CommandViewNodeContext & { node: ViewNode & { repo: Repository } } {
if (context.type !== 'viewItem') return false; if (context.type !== 'viewItem') return false;
return (context.node as ViewNode & { repo?: Repository }).repo instanceof Repository; return (context.node as ViewNode & { repo?: Repository }).repo instanceof Repository;
} }
export function isCommandViewContextWithRepoPath(
export function isCommandContextViewNodeHasRepoPath(
context: CommandContext, context: CommandContext,
): context is CommandViewItemContext & { node: ViewNode & { repoPath: string } } {
): context is CommandViewNodeContext & { node: ViewNode & { repoPath: string } } {
if (context.type !== 'viewItem') return false; if (context.type !== 'viewItem') return false;
return typeof (context.node as ViewNode & { repoPath?: string }).repoPath === 'string'; return typeof (context.node as ViewNode & { repoPath?: string }).repoPath === 'string';
} }
export function isCommandViewContextWithTag(
export function isCommandContextViewNodeHasTag(
context: CommandContext, context: CommandContext,
): context is CommandViewItemContext & { node: ViewNode & { tag: GitTag } } {
): context is CommandViewNodeContext & { node: ViewNode & { tag: GitTag } } {
if (context.type !== 'viewItem') return false; if (context.type !== 'viewItem') return false;
return GitTag.is((context.node as ViewNode & { tag: GitTag }).tag); return GitTag.is((context.node as ViewNode & { tag: GitTag }).tag);
@ -350,24 +350,23 @@ export type CommandContext =
| CommandUriContext | CommandUriContext
| CommandUrisContext | CommandUrisContext
// | CommandViewContext // | CommandViewContext
| CommandViewItemContext;
| CommandViewNodeContext;
function isScmResourceGroup(group: any): group is SourceControlResourceGroup { function isScmResourceGroup(group: any): group is SourceControlResourceGroup {
if (group == null) return false; if (group == null) return false;
return ( return (
(group as SourceControl).inputBox == null &&
(group as SourceControlResourceGroup).id != 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 { export abstract class Command implements Disposable {

+ 2
- 2
src/commands/copyMessageToClipboard.ts Datei anzeigen

@ -11,7 +11,7 @@ import {
CommandContext, CommandContext,
Commands, Commands,
getCommandUri, getCommandUri,
isCommandViewContextWithCommit,
isCommandContextViewNodeHasCommit,
} from './common'; } from './common';
export interface CopyMessageToClipboardCommandArgs { export interface CopyMessageToClipboardCommandArgs {
@ -26,7 +26,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
} }
protected preExecute(context: CommandContext, args?: CopyMessageToClipboardCommandArgs) { protected preExecute(context: CommandContext, args?: CopyMessageToClipboardCommandArgs) {
if (isCommandViewContextWithCommit(context)) {
if (isCommandContextViewNodeHasCommit(context)) {
args = { ...args }; args = { ...args };
args.sha = context.node.commit.sha; args.sha = context.node.commit.sha;
return this.execute(context.editor, context.node.commit.uri, args); return this.execute(context.editor, context.node.commit.uri, args);

+ 6
- 6
src/commands/copyShaToClipboard.ts Datei anzeigen

@ -11,9 +11,9 @@ import {
CommandContext, CommandContext,
Commands, Commands,
getCommandUri, getCommandUri,
isCommandViewContextWithBranch,
isCommandViewContextWithCommit,
isCommandViewContextWithTag,
isCommandContextViewNodeHasBranch,
isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasTag,
} from './common'; } from './common';
export interface CopyShaToClipboardCommandArgs { export interface CopyShaToClipboardCommandArgs {
@ -27,15 +27,15 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
} }
protected preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs) { protected preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs) {
if (isCommandViewContextWithCommit(context)) {
if (isCommandContextViewNodeHasCommit(context)) {
args = { ...args }; args = { ...args };
args.sha = context.node.commit.sha; args.sha = context.node.commit.sha;
return this.execute(context.editor, context.node.commit.uri, args); return this.execute(context.editor, context.node.commit.uri, args);
} else if (isCommandViewContextWithBranch(context)) {
} else if (isCommandContextViewNodeHasBranch(context)) {
args = { ...args }; args = { ...args };
args.sha = context.node.branch.sha; args.sha = context.node.branch.sha;
return this.execute(context.editor, context.node.uri, args); return this.execute(context.editor, context.node.uri, args);
} else if (isCommandViewContextWithTag(context)) {
} else if (isCommandContextViewNodeHasTag(context)) {
args = { ...args }; args = { ...args };
args.sha = context.node.tag.sha; args.sha = context.node.tag.sha;
return this.execute(context.editor, context.node.uri, args); return this.execute(context.editor, context.node.uri, args);

+ 4
- 4
src/commands/externalDiff.ts Datei anzeigen

@ -6,8 +6,8 @@ import {
CommandContext, CommandContext,
Commands, Commands,
getRepoPathOrPrompt, getRepoPathOrPrompt,
isCommandViewContextWithFileCommit,
isCommandViewContextWithFileRefs,
isCommandContextViewNodeHasFileCommit,
isCommandContextViewNodeHasFileRefs,
} from './common'; } from './common';
import { Container } from '../container'; import { Container } from '../container';
import { GitRevision } from '../git/git'; import { GitRevision } from '../git/git';
@ -68,7 +68,7 @@ export class ExternalDiffCommand extends Command {
protected async preExecute(context: CommandContext, args?: ExternalDiffCommandArgs) { protected async preExecute(context: CommandContext, args?: ExternalDiffCommandArgs) {
args = { ...args }; args = { ...args };
if (isCommandViewContextWithFileCommit(context)) {
if (isCommandContextViewNodeHasFileCommit(context)) {
const ref1 = GitRevision.isUncommitted(context.node.commit.previousFileSha) const ref1 = GitRevision.isUncommitted(context.node.commit.previousFileSha)
? '' ? ''
: context.node.commit.previousFileSha; : context.node.commit.previousFileSha;
@ -86,7 +86,7 @@ export class ExternalDiffCommand extends Command {
return this.execute(args); return this.execute(args);
} }
if (isCommandViewContextWithFileRefs(context)) {
if (isCommandContextViewNodeHasFileRefs(context)) {
args.files = [ args.files = [
{ {
uri: GitUri.fromFile(context.node.file, context.node.file.repoPath ?? context.node.repoPath), uri: GitUri.fromFile(context.node.file, context.node.file.repoPath ?? context.node.repoPath),

+ 2
- 2
src/commands/inviteToLiveShare.ts Datei anzeigen

@ -1,5 +1,5 @@
'use strict'; 'use strict';
import { command, Command, CommandContext, Commands, isCommandViewContextWithContributor } from './common';
import { command, Command, CommandContext, Commands, isCommandContextViewNodeHasContributor } from './common';
import { Container } from '../container'; import { Container } from '../container';
export interface InviteToLiveShareCommandArgs { export interface InviteToLiveShareCommandArgs {
@ -21,7 +21,7 @@ export class InviteToLiveShareCommand extends Command {
} }
protected preExecute(context: CommandContext, args?: InviteToLiveShareCommandArgs) { protected preExecute(context: CommandContext, args?: InviteToLiveShareCommandArgs) {
if (isCommandViewContextWithContributor(context)) {
if (isCommandContextViewNodeHasContributor(context)) {
args = { ...args }; args = { ...args };
args.email = context.node.contributor.email; args.email = context.node.contributor.email;
return this.execute(args); return this.execute(args);

+ 2
- 2
src/commands/openBranchOnRemote.ts Datei anzeigen

@ -8,7 +8,7 @@ import {
executeCommand, executeCommand,
getCommandUri, getCommandUri,
getRepoPathOrActiveOrPrompt, getRepoPathOrActiveOrPrompt,
isCommandViewContextWithBranch,
isCommandContextViewNodeHasBranch,
} from './common'; } from './common';
import { BranchSorting } from '../configuration'; import { BranchSorting } from '../configuration';
import { RemoteResourceType } from '../git/git'; import { RemoteResourceType } from '../git/git';
@ -30,7 +30,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand {
} }
protected preExecute(context: CommandContext, args?: OpenBranchOnRemoteCommandArgs) { protected preExecute(context: CommandContext, args?: OpenBranchOnRemoteCommandArgs) {
if (isCommandViewContextWithBranch(context)) {
if (isCommandContextViewNodeHasBranch(context)) {
args = { args = {
...args, ...args,
branch: context.node.branch.name, branch: context.node.branch.name,

+ 2
- 2
src/commands/openBranchesOnRemote.ts Datei anzeigen

@ -11,7 +11,7 @@ import {
executeCommand, executeCommand,
getCommandUri, getCommandUri,
getRepoPathOrActiveOrPrompt, getRepoPathOrActiveOrPrompt,
isCommandViewContextWithRemote,
isCommandContextViewNodeHasRemote,
} from './common'; } from './common';
import { OpenOnRemoteCommandArgs } from './openOnRemote'; import { OpenOnRemoteCommandArgs } from './openOnRemote';
@ -27,7 +27,7 @@ export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand {
} }
protected preExecute(context: CommandContext, args?: OpenBranchesOnRemoteCommandArgs) { protected preExecute(context: CommandContext, args?: OpenBranchesOnRemoteCommandArgs) {
if (isCommandViewContextWithRemote(context)) {
if (isCommandContextViewNodeHasRemote(context)) {
args = { ...args, remote: context.node.remote.name }; args = { ...args, remote: context.node.remote.name };
} }

+ 2
- 2
src/commands/openCommitOnRemote.ts Datei anzeigen

@ -7,7 +7,7 @@ import {
Commands, Commands,
executeCommand, executeCommand,
getCommandUri, getCommandUri,
isCommandViewContextWithCommit,
isCommandContextViewNodeHasCommit,
} from './common'; } from './common';
import { Container } from '../container'; import { Container } from '../container';
import { RemoteResourceType } from '../git/git'; import { RemoteResourceType } from '../git/git';
@ -37,7 +37,7 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand {
protected preExecute(context: CommandContext, args?: OpenCommitOnRemoteCommandArgs) { protected preExecute(context: CommandContext, args?: OpenCommitOnRemoteCommandArgs) {
let uri = context.uri; let uri = context.uri;
if (isCommandViewContextWithCommit(context)) {
if (isCommandContextViewNodeHasCommit(context)) {
if (context.node.commit.isUncommitted) return Promise.resolve(undefined); if (context.node.commit.isUncommitted) return Promise.resolve(undefined);
args = { ...args, sha: context.node.commit.sha }; args = { ...args, sha: context.node.commit.sha };

+ 2
- 2
src/commands/openDirectoryCompare.ts Datei anzeigen

@ -7,7 +7,7 @@ import {
Commands, Commands,
getCommandUri, getCommandUri,
getRepoPathOrActiveOrPrompt, getRepoPathOrActiveOrPrompt,
isCommandViewContextWithRef,
isCommandContextViewNodeHasRef,
} from './common'; } from './common';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
@ -47,7 +47,7 @@ export class OpenDirectoryCompareCommand extends ActiveEditorCommand {
break; break;
case Commands.ViewsOpenDirectoryDiffWithWorking: case Commands.ViewsOpenDirectoryDiffWithWorking:
if (isCommandViewContextWithRef(context)) {
if (isCommandContextViewNodeHasRef(context)) {
args = { ...args }; args = { ...args };
args.ref1 = context.node.ref; args.ref1 = context.node.ref;
args.ref2 = undefined; args.ref2 = undefined;

+ 4
- 4
src/commands/openFileOnRemote.ts Datei anzeigen

@ -7,8 +7,8 @@ import {
Commands, Commands,
executeCommand, executeCommand,
getCommandUri, getCommandUri,
isCommandViewContextWithBranch,
isCommandViewContextWithCommit,
isCommandContextViewNodeHasBranch,
isCommandContextViewNodeHasCommit,
} from './common'; } from './common';
import { UriComparer } from '../comparers'; import { UriComparer } from '../comparers';
import { BranchSorting } from '../configuration'; import { BranchSorting } from '../configuration';
@ -40,13 +40,13 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
if (context.type === 'uris' || context.type === 'scm-states') { if (context.type === 'uris' || context.type === 'scm-states') {
args = { ...args, range: false }; args = { ...args, range: false };
} else if (isCommandViewContextWithCommit(context)) {
} else if (isCommandContextViewNodeHasCommit(context)) {
args = { ...args, range: false }; args = { ...args, range: false };
if (context.command === Commands.CopyRemoteFileUrl) { if (context.command === Commands.CopyRemoteFileUrl) {
// If it is a StatusFileNode then don't include the sha, since it hasn't been pushed yet // 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; 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; args.branch = context.node.branch?.name;
} }

+ 3
- 3
src/commands/openPullRequestOnRemote.ts Datei anzeigen

@ -5,8 +5,8 @@ import {
command, command,
CommandContext, CommandContext,
Commands, Commands,
isCommandViewContextWithCommit,
isCommandViewContextWithFileCommit,
isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasFileCommit,
} from './common'; } from './common';
import { Container } from '../container'; import { Container } from '../container';
import { PullRequestNode } from '../views/nodes/pullRequestNode'; import { PullRequestNode } from '../views/nodes/pullRequestNode';
@ -31,7 +31,7 @@ export class OpenPullRequestOnRemoteCommand extends Command {
pr: { url: context.node.pullRequest.url }, 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 }; args = { ...args, ref: context.node.commit.sha, repoPath: context.node.commit.repoPath };
} }

+ 2
- 2
src/commands/openRepoOnRemote.ts Datei anzeigen

@ -8,7 +8,7 @@ import {
executeCommand, executeCommand,
getCommandUri, getCommandUri,
getRepoPathOrActiveOrPrompt, getRepoPathOrActiveOrPrompt,
isCommandViewContextWithRemote,
isCommandContextViewNodeHasRemote,
} from './common'; } from './common';
import { RemoteResourceType } from '../git/git'; import { RemoteResourceType } from '../git/git';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
@ -27,7 +27,7 @@ export class OpenRepoOnRemoteCommand extends ActiveEditorCommand {
} }
protected preExecute(context: CommandContext, args?: OpenRepoOnRemoteCommandArgs) { protected preExecute(context: CommandContext, args?: OpenRepoOnRemoteCommandArgs) {
if (isCommandViewContextWithRemote(context)) {
if (isCommandContextViewNodeHasRemote(context)) {
args = { ...args, remote: context.node.remote.name }; args = { ...args, remote: context.node.remote.name };
} }

+ 3
- 3
src/commands/remoteProviders.ts Datei anzeigen

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { GitCommit, GitRemote } from '../git/git'; 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'; import { Container } from '../container';
export interface ConnectRemoteProviderCommandArgs { export interface ConnectRemoteProviderCommandArgs {
@ -31,7 +31,7 @@ export class ConnectRemoteProviderCommand extends Command {
} }
protected preExecute(context: CommandContext, args?: ConnectRemoteProviderCommandArgs) { protected preExecute(context: CommandContext, args?: ConnectRemoteProviderCommandArgs) {
if (isCommandViewContextWithRemote(context)) {
if (isCommandContextViewNodeHasRemote(context)) {
args = { ...args, remote: context.node.remote.id, repoPath: context.node.remote.repoPath }; 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) { protected preExecute(context: CommandContext, args?: ConnectRemoteProviderCommandArgs) {
if (isCommandViewContextWithRemote(context)) {
if (isCommandContextViewNodeHasRemote(context)) {
args = { ...args, remote: context.node.remote.id, repoPath: context.node.remote.repoPath }; args = { ...args, remote: context.node.remote.id, repoPath: context.node.remote.repoPath };
} }

+ 2
- 2
src/commands/searchCommits.ts Datei anzeigen

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { executeGitCommand } from '../commands'; 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 { Container } from '../container';
import { SearchPattern } from '../git/git'; import { SearchPattern } from '../git/git';
import { SearchResultsNode } from '../views/nodes'; import { SearchResultsNode } from '../views/nodes';
@ -31,7 +31,7 @@ export class SearchCommitsCommand extends Command {
args.prefillOnly = true; args.prefillOnly = true;
} }
if (isCommandViewContextWithRepo(context)) {
if (isCommandContextViewNodeHasRepository(context)) {
args.repoPath = context.node.repo.path; args.repoPath = context.node.repo.path;
} }
} else if (context.command === Commands.SearchCommitsInView) { } else if (context.command === Commands.SearchCommitsInView) {

+ 2
- 2
src/commands/showQuickCommit.ts Datei anzeigen

@ -6,7 +6,7 @@ import {
CommandContext, CommandContext,
Commands, Commands,
getCommandUri, getCommandUri,
isCommandViewContextWithCommit,
isCommandContextViewNodeHasCommit,
} from './common'; } from './common';
import { Container } from '../container'; import { Container } from '../container';
import { GitCommit, GitLog, GitLogCommit } from '../git/git'; import { GitCommit, GitLog, GitLogCommit } from '../git/git';
@ -46,7 +46,7 @@ export class ShowQuickCommitCommand extends ActiveEditorCachedCommand {
args = { ...args }; args = { ...args };
args.sha = context.node.uri.sha; args.sha = context.node.uri.sha;
if (isCommandViewContextWithCommit(context)) {
if (isCommandContextViewNodeHasCommit(context)) {
args.commit = context.node.commit; args.commit = context.node.commit;
} }
} }

+ 2
- 2
src/commands/showQuickCommitFile.ts Datei anzeigen

@ -6,7 +6,7 @@ import {
CommandContext, CommandContext,
Commands, Commands,
getCommandUri, getCommandUri,
isCommandViewContextWithCommit,
isCommandContextViewNodeHasCommit,
} from './common'; } from './common';
import { Container } from '../container'; import { Container } from '../container';
import { GitBlameCommit, GitCommit, GitLog, GitLogCommit } from '../git/git'; import { GitBlameCommit, GitCommit, GitLog, GitLogCommit } from '../git/git';
@ -49,7 +49,7 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand {
args = { ...args }; args = { ...args };
args.sha = context.node.uri.sha; args.sha = context.node.uri.sha;
if (isCommandViewContextWithCommit(context)) {
if (isCommandContextViewNodeHasCommit(context)) {
args.commit = context.node.commit; args.commit = context.node.commit;
} }
} }

+ 4
- 4
src/commands/stashApply.ts Datei anzeigen

@ -5,8 +5,8 @@ import {
Command, Command,
CommandContext, CommandContext,
Commands, Commands,
isCommandViewContextWithCommit,
isCommandViewContextWithRepo,
isCommandContextViewNodeHasCommit,
isCommandContextViewNodeHasRepository,
} from './common'; } from './common';
import { GitStashCommit, GitStashReference } from '../git/git'; import { GitStashCommit, GitStashReference } from '../git/git';
import { CommandQuickPickItem } from '../quickpicks'; import { CommandQuickPickItem } from '../quickpicks';
@ -26,9 +26,9 @@ export class StashApplyCommand extends Command {
} }
protected preExecute(context: CommandContext, args?: StashApplyCommandArgs) { protected preExecute(context: CommandContext, args?: StashApplyCommandArgs) {
if (isCommandViewContextWithCommit<GitStashCommit>(context)) {
if (isCommandContextViewNodeHasCommit<GitStashCommit>(context)) {
args = { ...args, stashItem: context.node.commit }; args = { ...args, stashItem: context.node.commit };
} else if (isCommandViewContextWithRepo(context)) {
} else if (isCommandContextViewNodeHasRepository(context)) {
args = { ...args, repoPath: context.node.repo.path }; args = { ...args, repoPath: context.node.repo.path };
} }

+ 7
- 7
src/commands/stashSave.ts Datei anzeigen

@ -2,13 +2,13 @@
import { Uri } from 'vscode'; import { Uri } from 'vscode';
import { GitActions } from '../commands'; import { GitActions } from '../commands';
import { import {
command,
Command, Command,
command,
CommandContext, CommandContext,
Commands, Commands,
isCommandViewContextWithFile,
isCommandViewContextWithRepo,
isCommandViewContextWithRepoPath,
isCommandContextViewNodeHasFile,
isCommandContextViewNodeHasRepoPath,
isCommandContextViewNodeHasRepository,
} from './common'; } from './common';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitUri'; import { GitUri } from '../git/gitUri';
@ -33,14 +33,14 @@ export class StashSaveCommand extends Command {
} }
protected async preExecute(context: CommandContext, args?: StashSaveCommandArgs) { protected async preExecute(context: CommandContext, args?: StashSaveCommandArgs) {
if (isCommandViewContextWithFile(context)) {
if (isCommandContextViewNodeHasFile(context)) {
args = { ...args }; args = { ...args };
args.repoPath = context.node.file.repoPath ?? context.node.repoPath; args.repoPath = context.node.file.repoPath ?? context.node.repoPath;
args.uris = [GitUri.fromFile(context.node.file, args.repoPath)]; args.uris = [GitUri.fromFile(context.node.file, args.repoPath)];
} else if (isCommandViewContextWithRepo(context)) {
} else if (isCommandContextViewNodeHasRepository(context)) {
args = { ...args }; args = { ...args };
args.repoPath = context.node.repo.path; args.repoPath = context.node.repo.path;
} else if (isCommandViewContextWithRepoPath(context)) {
} else if (isCommandContextViewNodeHasRepoPath(context)) {
args = { ...args }; args = { ...args };
args.repoPath = context.node.repoPath; args.repoPath = context.node.repoPath;
} else if (context.type === 'scm-states') { } else if (context.type === 'scm-states') {

Laden…
Abbrechen
Speichern