Skip to content

Commit 7bf410b

Browse files
Renames GitCommands command to QuickWizard (#3588)
* Renames GitCommands command to QuickWizard Updates telemetry source to 'quick-wizard' * Splits out git commands to git wizard Authored by: Eric Amodio @eamodio
1 parent 3077ecc commit 7bf410b

24 files changed

+352
-342
lines changed

src/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import './commands/diffWithWorking';
2323
import './commands/externalDiff';
2424
import './commands/generateCommitMessage';
2525
import './commands/ghpr/openOrCreateWorktree';
26-
import './commands/gitCommands';
26+
import './commands/gitWizard';
2727
import './commands/inviteToLiveShare';
2828
import './commands/inspect';
2929
import './commands/logging';
@@ -44,6 +44,7 @@ import './commands/openRepoOnRemote';
4444
import './commands/openRevisionFile';
4545
import './commands/openWorkingFile';
4646
import './commands/patches';
47+
import './commands/quickWizard';
4748
import './commands/rebaseEditor';
4849
import './commands/refreshHover';
4950
import './commands/remoteProviders';

src/commands/git/branch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
1212
import { ensureArray } from '../../system/array';
1313
import { pluralize } from '../../system/string';
1414
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
15-
import { getSteps } from '../gitCommands.utils';
1615
import type {
1716
AsyncStepResultGenerator,
1817
PartialStepState,
@@ -38,6 +37,7 @@ import {
3837
pickBranchStep,
3938
pickRepositoryStep,
4039
} from '../quickCommand.steps';
40+
import { getSteps } from '../quickWizard.utils';
4141

4242
interface Context {
4343
repos: Repository[];

src/commands/git/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { Repository } from '../../git/models/repository';
99
import { pad } from '../../system/string';
1010
import { formatPath } from '../../system/vscode/formatPath';
1111
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
12-
import { getSteps } from '../gitCommands.utils';
1312
import type { PartialStepState, StepGenerator, StepResult } from '../quickCommand';
1413
import { endSteps, QuickCommand, StepResultBreak } from '../quickCommand';
1514
import { pickBranchOrTagStep, pickCommitStep, pickRepositoryStep } from '../quickCommand.steps';
15+
import { getSteps } from '../quickWizard.utils';
1616

1717
interface Context {
1818
repos: Repository[];

src/commands/git/search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { configuration } from '../../system/vscode/configuration';
1919
import { getContext } from '../../system/vscode/context';
2020
import { SearchResultsNode } from '../../views/nodes/searchResultsNode';
2121
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
22-
import { getSteps } from '../gitCommands.utils';
2322
import type {
2423
PartialStepState,
2524
QuickPickStep,
@@ -44,6 +43,7 @@ import {
4443
ShowResultsInSideBarQuickInputButton,
4544
} from '../quickCommand.buttons';
4645
import { appendReposToTitle, pickCommitStep, pickRepositoryStep } from '../quickCommand.steps';
46+
import { getSteps } from '../quickWizard.utils';
4747

4848
const UseAuthorPickerQuickInputButton: QuickInputButton = {
4949
iconPath: new ThemeIcon('person-add'),

src/commands/git/show.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { GitRevisionReference } from '../../git/models/reference';
55
import { Repository } from '../../git/models/repository';
66
import { CommitFilesQuickPickItem } from '../../quickpicks/items/commits';
77
import { CommandQuickPickItem } from '../../quickpicks/items/common';
8-
import { GitCommandQuickPickItem } from '../../quickpicks/items/gitCommands';
8+
import { GitWizardQuickPickItem } from '../../quickpicks/items/gitWizard';
99
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
1010
import type { PartialStepState, StepGenerator } from '../quickCommand';
1111
import { endSteps, QuickCommand, StepResultBreak } from '../quickCommand';
@@ -181,7 +181,7 @@ export class ShowGitCommand extends QuickCommand<State> {
181181
const result = yield* showCommitOrStashStep(state, context);
182182
if (result === StepResultBreak) continue;
183183

184-
if (result instanceof GitCommandQuickPickItem) {
184+
if (result instanceof GitWizardQuickPickItem) {
185185
const r = yield* result.executeSteps(this.pickedVia);
186186
state.counter--;
187187
if (r === StepResultBreak) {
@@ -227,7 +227,7 @@ export class ShowGitCommand extends QuickCommand<State> {
227227
continue;
228228
}
229229

230-
if (result instanceof GitCommandQuickPickItem) {
230+
if (result instanceof GitWizardQuickPickItem) {
231231
yield* result.executeSteps(this.pickedVia);
232232
state.counter--;
233233

src/commands/git/stash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { pad } from '../../system/string';
1717
import { getContext } from '../../system/vscode/context';
1818
import { formatPath } from '../../system/vscode/formatPath';
1919
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
20-
import { getSteps } from '../gitCommands.utils';
2120
import type {
2221
AsyncStepResultGenerator,
2322
PartialStepState,
@@ -39,6 +38,7 @@ import {
3938
} from '../quickCommand';
4039
import { RevealInSideBarQuickInputButton, ShowDetailsViewQuickInputButton } from '../quickCommand.buttons';
4140
import { appendReposToTitle, pickRepositoryStep, pickStashesStep, pickStashStep } from '../quickCommand.steps';
41+
import { getSteps } from '../quickWizard.utils';
4242

4343
interface Context {
4444
repos: Repository[];

src/commands/git/status.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createReference, getReferenceLabel } from '../../git/models/reference';
44
import type { Repository } from '../../git/models/repository';
55
import type { GitStatus } from '../../git/models/status';
66
import { CommandQuickPickItem } from '../../quickpicks/items/common';
7-
import { GitCommandQuickPickItem } from '../../quickpicks/items/gitCommands';
7+
import { GitWizardQuickPickItem } from '../../quickpicks/items/gitWizard';
88
import { pad } from '../../system/string';
99
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
1010
import type { PartialStepState, StepGenerator, StepState } from '../quickCommand';
@@ -105,7 +105,7 @@ export class StatusGitCommand extends QuickCommand<State> {
105105
continue;
106106
}
107107

108-
if (result instanceof GitCommandQuickPickItem) {
108+
if (result instanceof GitWizardQuickPickItem) {
109109
const r = yield* result.executeSteps(this.pickedVia);
110110
state.counter--;
111111
if (r === StepResultBreak) {

src/commands/git/switch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { createQuickPickSeparator } from '../../quickpicks/items/common';
1313
import { isStringArray } from '../../system/array';
1414
import { executeCommand } from '../../system/vscode/command';
1515
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
16-
import { getSteps } from '../gitCommands.utils';
1716
import type { PartialStepState, StepGenerator, StepResultGenerator, StepSelection, StepState } from '../quickCommand';
1817
import { canPickStepContinue, endSteps, isCrossCommandReference, QuickCommand, StepResultBreak } from '../quickCommand';
1918
import {
@@ -22,6 +21,7 @@ import {
2221
pickBranchOrTagStepMultiRepo,
2322
pickRepositoriesStep,
2423
} from '../quickCommand.steps';
24+
import { getSteps } from '../quickWizard.utils';
2525

2626
interface Context {
2727
repos: Repository[];

src/commands/git/worktree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import { configuration } from '../../system/vscode/configuration';
4040
import { isDescendant } from '../../system/vscode/path';
4141
import { getWorkspaceFriendlyPath, openWorkspace, revealInFileExplorer } from '../../system/vscode/utils';
4242
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
43-
import { getSteps } from '../gitCommands.utils';
4443
import type {
4544
AsyncStepResultGenerator,
4645
CustomStep,
@@ -70,6 +69,7 @@ import {
7069
pickWorktreesStep,
7170
pickWorktreeStep,
7271
} from '../quickCommand.steps';
72+
import { getSteps } from '../quickWizard.utils';
7373

7474
interface Context {
7575
repos: Repository[];

src/commands/gitWizard.ts

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
import { Commands } from '../constants.commands';
2+
import type { Container } from '../container';
3+
import { command } from '../system/vscode/command';
4+
import type { CommandContext } from './base';
5+
import type { BranchGitCommandArgs } from './git/branch';
6+
import type { CherryPickGitCommandArgs } from './git/cherry-pick';
7+
import type { CoAuthorsGitCommandArgs } from './git/coauthors';
8+
import type { FetchGitCommandArgs } from './git/fetch';
9+
import type { LogGitCommandArgs } from './git/log';
10+
import type { MergeGitCommandArgs } from './git/merge';
11+
import type { PullGitCommandArgs } from './git/pull';
12+
import type { PushGitCommandArgs } from './git/push';
13+
import type { RebaseGitCommandArgs } from './git/rebase';
14+
import type { RemoteGitCommandArgs } from './git/remote';
15+
import type { ResetGitCommandArgs } from './git/reset';
16+
import type { RevertGitCommandArgs } from './git/revert';
17+
import type { SearchGitCommandArgs } from './git/search';
18+
import type { ShowGitCommandArgs } from './git/show';
19+
import type { StashGitCommandArgs } from './git/stash';
20+
import type { StatusGitCommandArgs } from './git/status';
21+
import type { SwitchGitCommandArgs } from './git/switch';
22+
import type { TagGitCommandArgs } from './git/tag';
23+
import type { WorktreeGitCommandArgs } from './git/worktree';
24+
import type { QuickWizardCommandArgsWithCompletion } from './quickWizard.base';
25+
import { QuickWizardCommandBase } from './quickWizard.base';
26+
27+
export type GitWizardCommandArgs =
28+
| BranchGitCommandArgs
29+
| CherryPickGitCommandArgs
30+
| CoAuthorsGitCommandArgs
31+
| FetchGitCommandArgs
32+
| LogGitCommandArgs
33+
| MergeGitCommandArgs
34+
| PullGitCommandArgs
35+
| PushGitCommandArgs
36+
| RebaseGitCommandArgs
37+
| RemoteGitCommandArgs
38+
| ResetGitCommandArgs
39+
| RevertGitCommandArgs
40+
| SearchGitCommandArgs
41+
| ShowGitCommandArgs
42+
| StashGitCommandArgs
43+
| StatusGitCommandArgs
44+
| SwitchGitCommandArgs
45+
| TagGitCommandArgs
46+
| WorktreeGitCommandArgs;
47+
48+
@command()
49+
export class GitWizardCommand extends QuickWizardCommandBase {
50+
constructor(container: Container) {
51+
super(container, [
52+
Commands.GitCommands,
53+
Commands.GitCommandsBranch,
54+
Commands.GitCommandsBranchCreate,
55+
Commands.GitCommandsBranchDelete,
56+
Commands.GitCommandsBranchPrune,
57+
Commands.GitCommandsBranchRename,
58+
Commands.GitCommandsCheckout,
59+
Commands.GitCommandsCherryPick,
60+
Commands.GitCommandsHistory,
61+
Commands.GitCommandsMerge,
62+
Commands.GitCommandsRebase,
63+
Commands.GitCommandsRemote,
64+
Commands.GitCommandsRemoteAdd,
65+
Commands.GitCommandsRemotePrune,
66+
Commands.GitCommandsRemoteRemove,
67+
Commands.GitCommandsReset,
68+
Commands.GitCommandsRevert,
69+
Commands.GitCommandsShow,
70+
Commands.GitCommandsStash,
71+
Commands.GitCommandsStashDrop,
72+
Commands.GitCommandsStashList,
73+
Commands.GitCommandsStashPop,
74+
Commands.GitCommandsStashPush,
75+
Commands.GitCommandsStashRename,
76+
Commands.GitCommandsStatus,
77+
Commands.GitCommandsSwitch,
78+
Commands.GitCommandsTag,
79+
Commands.GitCommandsTagCreate,
80+
Commands.GitCommandsTagDelete,
81+
Commands.GitCommandsWorktree,
82+
Commands.GitCommandsWorktreeCreate,
83+
Commands.GitCommandsWorktreeDelete,
84+
Commands.GitCommandsWorktreeOpen,
85+
86+
Commands.CopyWorkingChangesToWorktree,
87+
]);
88+
}
89+
90+
protected override preExecute(
91+
context: CommandContext,
92+
args?: QuickWizardCommandArgsWithCompletion<GitWizardCommandArgs>,
93+
) {
94+
switch (context.command) {
95+
case Commands.GitCommandsBranch:
96+
return this.execute({ command: 'branch' });
97+
case Commands.GitCommandsBranchCreate:
98+
return this.execute({ command: 'branch', state: { subcommand: 'create' } });
99+
case Commands.GitCommandsBranchDelete:
100+
return this.execute({ command: 'branch', state: { subcommand: 'delete' } });
101+
case Commands.GitCommandsBranchPrune:
102+
return this.execute({ command: 'branch', state: { subcommand: 'prune' } });
103+
case Commands.GitCommandsBranchRename:
104+
return this.execute({ command: 'branch', state: { subcommand: 'rename' } });
105+
case Commands.GitCommandsCherryPick:
106+
return this.execute({ command: 'cherry-pick' });
107+
case Commands.GitCommandsHistory:
108+
return this.execute({ command: 'log' });
109+
case Commands.GitCommandsMerge:
110+
return this.execute({ command: 'merge' });
111+
case Commands.GitCommandsRebase:
112+
return this.execute({ command: 'rebase' });
113+
case Commands.GitCommandsRemote:
114+
return this.execute({ command: 'remote' });
115+
case Commands.GitCommandsRemoteAdd:
116+
return this.execute({ command: 'remote', state: { subcommand: 'add' } });
117+
case Commands.GitCommandsRemotePrune:
118+
return this.execute({ command: 'remote', state: { subcommand: 'prune' } });
119+
case Commands.GitCommandsRemoteRemove:
120+
return this.execute({ command: 'remote', state: { subcommand: 'remove' } });
121+
case Commands.GitCommandsReset:
122+
return this.execute({ command: 'reset' });
123+
case Commands.GitCommandsRevert:
124+
return this.execute({ command: 'revert' });
125+
case Commands.GitCommandsShow:
126+
return this.execute({ command: 'show' });
127+
case Commands.GitCommandsStash:
128+
return this.execute({ command: 'stash' });
129+
case Commands.GitCommandsStashDrop:
130+
return this.execute({ command: 'stash', state: { subcommand: 'drop' } });
131+
case Commands.GitCommandsStashList:
132+
return this.execute({ command: 'stash', state: { subcommand: 'list' } });
133+
case Commands.GitCommandsStashPop:
134+
return this.execute({ command: 'stash', state: { subcommand: 'pop' } });
135+
case Commands.GitCommandsStashPush:
136+
return this.execute({ command: 'stash', state: { subcommand: 'push' } });
137+
case Commands.GitCommandsStashRename:
138+
return this.execute({ command: 'stash', state: { subcommand: 'rename' } });
139+
case Commands.GitCommandsStatus:
140+
return this.execute({ command: 'status' });
141+
case Commands.GitCommandsSwitch:
142+
case Commands.GitCommandsCheckout:
143+
return this.execute({ command: 'switch' });
144+
case Commands.GitCommandsTag:
145+
return this.execute({ command: 'tag' });
146+
case Commands.GitCommandsTagCreate:
147+
return this.execute({ command: 'tag', state: { subcommand: 'create' } });
148+
case Commands.GitCommandsTagDelete:
149+
return this.execute({ command: 'tag', state: { subcommand: 'delete' } });
150+
case Commands.GitCommandsWorktree:
151+
return this.execute({ command: 'worktree' });
152+
case Commands.GitCommandsWorktreeCreate:
153+
return this.execute({ command: 'worktree', state: { subcommand: 'create' } });
154+
case Commands.GitCommandsWorktreeDelete:
155+
return this.execute({ command: 'worktree', state: { subcommand: 'delete' } });
156+
case Commands.GitCommandsWorktreeOpen:
157+
return this.execute({ command: 'worktree', state: { subcommand: 'open' } });
158+
159+
case Commands.CopyWorkingChangesToWorktree:
160+
return this.execute({
161+
command: 'worktree',
162+
state: { subcommand: 'copy-changes', changes: { type: 'working-tree' } },
163+
});
164+
165+
default:
166+
return this.execute(args);
167+
}
168+
}
169+
}

0 commit comments

Comments
 (0)