Browse Source

Removes StepResult namespace

main
Eric Amodio 1 year ago
parent
commit
220cb91eb5
22 changed files with 228 additions and 209 deletions
  1. +16
    -16
      src/commands/git/branch.ts
  2. +8
    -7
      src/commands/git/cherry-pick.ts
  3. +4
    -4
      src/commands/git/coauthors.ts
  4. +5
    -5
      src/commands/git/fetch.ts
  5. +15
    -8
      src/commands/git/log.ts
  6. +9
    -8
      src/commands/git/merge.ts
  7. +5
    -5
      src/commands/git/pull.ts
  8. +6
    -6
      src/commands/git/push.ts
  9. +9
    -8
      src/commands/git/rebase.ts
  10. +15
    -15
      src/commands/git/remote.ts
  11. +7
    -6
      src/commands/git/reset.ts
  12. +7
    -6
      src/commands/git/revert.ts
  13. +16
    -9
      src/commands/git/search.ts
  14. +10
    -9
      src/commands/git/show.ts
  15. +18
    -17
      src/commands/git/stash.ts
  16. +4
    -4
      src/commands/git/status.ts
  17. +7
    -7
      src/commands/git/switch.ts
  18. +14
    -14
      src/commands/git/tag.ts
  19. +18
    -18
      src/commands/git/worktree.ts
  20. +2
    -2
      src/commands/gitCommands.ts
  21. +26
    -26
      src/commands/quickCommand.steps.ts
  22. +7
    -9
      src/commands/quickCommand.ts

+ 16
- 16
src/commands/git/branch.ts View File

@ -29,7 +29,7 @@ import {
pickBranchStep,
pickRepositoryStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -205,7 +205,7 @@ export class BranchGitCommand extends QuickCommand {
const result = yield* this.pickSubcommandStep(state);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.subcommand = result;
}
@ -223,7 +223,7 @@ export class BranchGitCommand extends QuickCommand {
state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.repo = result;
}
@ -257,7 +257,7 @@ export class BranchGitCommand extends QuickCommand {
}
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *pickSubcommandStep(state: PartialStepState<State>): StepResultGenerator<State['subcommand']> {
@ -287,7 +287,7 @@ export class BranchGitCommand extends QuickCommand {
buttons: [QuickInputButtons.Back],
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *createCommandSteps(state: CreateStepState, context: Context): AsyncStepResultGenerator<void> {
@ -305,7 +305,7 @@ export class BranchGitCommand extends QuickCommand {
value: GitReference.isRevision(state.reference) ? state.reference.ref : undefined,
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.reference = result;
}
@ -320,14 +320,14 @@ export class BranchGitCommand extends QuickCommand {
})}`,
value: state.name ?? GitReference.getNameWithoutRemote(state.reference),
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.name = result;
}
if (this.confirm(state.confirm)) {
const result = yield* this.createCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
}
@ -365,7 +365,7 @@ export class BranchGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *deleteCommandSteps(state: DeleteStepState, context: Context): AsyncStepResultGenerator<void> {
@ -392,7 +392,7 @@ export class BranchGitCommand extends QuickCommand {
sort: { current: false, missingUpstream: true },
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.references = result;
}
@ -404,7 +404,7 @@ export class BranchGitCommand extends QuickCommand {
assertStateStepDeleteBranches(state);
const result = yield* this.deleteCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
@ -465,7 +465,7 @@ export class BranchGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *renameCommandSteps(state: RenameStepState, context: Context): AsyncStepResultGenerator<void> {
@ -481,7 +481,7 @@ export class BranchGitCommand extends QuickCommand {
placeholder: 'Choose a branch to rename',
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.reference = result;
}
@ -494,13 +494,13 @@ export class BranchGitCommand extends QuickCommand {
titleContext: ` ${GitReference.toString(state.reference, false)}`,
value: state.name ?? state.reference.name,
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.name = result;
}
const result = yield* this.renameCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
@ -524,6 +524,6 @@ export class BranchGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 8
- 7
src/commands/git/cherry-pick.ts View File

@ -10,6 +10,7 @@ import type {
PartialStepState,
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
@ -23,7 +24,7 @@ import {
pickCommitsStep,
pickRepositoryStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -124,7 +125,7 @@ export class CherryPickGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -151,7 +152,7 @@ export class CherryPickGitCommand extends QuickCommand {
value: context.selectedBranchOrTag == null ? state.references?.[0]?.ref : undefined,
},
);
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -194,14 +195,14 @@ export class CherryPickGitCommand extends QuickCommand {
})}`,
},
);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.references = result;
}
if (this.confirm(state.confirm)) {
const result = yield* this.confirmStep(state as CherryPickStepState, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
}
@ -210,7 +211,7 @@ export class CherryPickGitCommand extends QuickCommand {
this.execute(state as CherryPickStepState<State<GitReference[]>>);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *confirmStep(state: CherryPickStepState, context: Context): StepResultGenerator<Flags[]> {
@ -241,6 +242,6 @@ export class CherryPickGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 4
- 4
src/commands/git/coauthors.ts View File

@ -6,7 +6,7 @@ import { executeCoreCommand } from '../../system/command';
import { normalizePath } from '../../system/path';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type { PartialStepState, StepGenerator, StepState } from '../quickCommand';
import { endSteps , pickContributorsStep, pickRepositoryStep, QuickCommand, StepResult } from '../quickCommand';
import { endSteps, pickContributorsStep, pickRepositoryStep, QuickCommand, StepResultBreak } from '../quickCommand';
interface Context {
repos: Repository[];
@ -130,7 +130,7 @@ export class CoAuthorsGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -142,7 +142,7 @@ export class CoAuthorsGitCommand extends QuickCommand {
context,
'Choose contributors to add as co-authors',
);
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -158,6 +158,6 @@ export class CoAuthorsGitCommand extends QuickCommand {
void this.execute(state as CoAuthorStepState);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
}

+ 5
- 5
src/commands/git/fetch.ts View File

@ -24,7 +24,7 @@ import {
endSteps,
pickRepositoriesStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -110,7 +110,7 @@ export class FetchGitCommand extends QuickCommand {
{ skipIfPossible: state.counter >= 1 },
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repos = result;
}
@ -118,7 +118,7 @@ export class FetchGitCommand extends QuickCommand {
if (this.confirm(state.confirm)) {
const result = yield* this.confirmStep(state as FetchStepState, context);
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -134,7 +134,7 @@ export class FetchGitCommand extends QuickCommand {
void this.execute(state as FetchStepState);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private async *confirmStep(state: FetchStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
@ -192,6 +192,6 @@ export class FetchGitCommand extends QuickCommand {
}
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 15
- 8
src/commands/git/log.ts View File

@ -9,8 +9,15 @@ import { formatPath } from '../../system/formatPath';
import { pad } from '../../system/string';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { getSteps } from '../gitCommands.utils';
import type { PartialStepState, StepGenerator } from '../quickCommand';
import { endSteps , pickBranchOrTagStep, pickCommitStep, pickRepositoryStep, QuickCommand, StepResult } from '../quickCommand';
import type { PartialStepState, StepGenerator, StepResult } from '../quickCommand';
import {
endSteps,
pickBranchOrTagStep,
pickCommitStep,
pickRepositoryStep,
QuickCommand,
StepResultBreak,
} from '../quickCommand';
interface Context {
repos: Repository[];
@ -107,7 +114,7 @@ export class LogGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -127,7 +134,7 @@ export class LogGitCommand extends QuickCommand {
value: context.selectedBranchOrTag == null ? state.reference?.ref : undefined,
ranges: true,
});
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -180,7 +187,7 @@ export class LogGitCommand extends QuickCommand {
: 'Choose a commit',
picked: state.reference?.ref,
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.reference = result;
}
@ -195,7 +202,7 @@ export class LogGitCommand extends QuickCommand {
pin: false,
preserveFocus: false,
});
result = StepResult.Break;
result = StepResultBreak;
} else {
result = yield* getSteps(
this.container,
@ -212,11 +219,11 @@ export class LogGitCommand extends QuickCommand {
}
state.counter--;
if (result === StepResult.Break) {
if (result === StepResultBreak) {
endSteps(state);
}
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
}

+ 9
- 8
src/commands/git/merge.ts View File

@ -14,6 +14,7 @@ import type {
PartialStepState,
QuickPickStep,
StepGenerator,
StepResult,
StepSelection,
StepState,
} from '../quickCommand';
@ -26,7 +27,7 @@ import {
pickRepositoryStep,
QuickCommand,
QuickCommandButtons,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -120,7 +121,7 @@ export class MergeGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -148,7 +149,7 @@ export class MergeGitCommand extends QuickCommand {
value: context.selectedBranchOrTag == null ? state.reference?.ref : undefined,
additionalButtons: [pickCommitToggle],
});
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -192,13 +193,13 @@ export class MergeGitCommand extends QuickCommand {
})}`,
picked: state.reference?.ref,
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.reference = result;
}
const result = yield* this.confirmStep(state as MergeStepState, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
@ -206,7 +207,7 @@ export class MergeGitCommand extends QuickCommand {
this.execute(state as MergeStepState);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private async *confirmStep(state: MergeStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
@ -227,7 +228,7 @@ export class MergeGitCommand extends QuickCommand {
);
const selection: StepSelection<typeof step> = yield step;
canPickStepContinue(step, state, selection);
return StepResult.Break;
return StepResultBreak;
}
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
@ -273,6 +274,6 @@ export class MergeGitCommand extends QuickCommand {
],
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 5
- 5
src/commands/git/pull.ts View File

@ -26,7 +26,7 @@ import {
pickRepositoriesStep,
QuickCommand,
QuickCommandButtons,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -117,7 +117,7 @@ export class PullGitCommand extends QuickCommand {
{ skipIfPossible: state.counter >= 1 },
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repos = result;
}
@ -125,7 +125,7 @@ export class PullGitCommand extends QuickCommand {
if (this.confirm(state.confirm)) {
const result = yield* this.confirmStep(state as PullStepState, context);
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -141,7 +141,7 @@ export class PullGitCommand extends QuickCommand {
void this.execute(state as PullStepState);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private async *confirmStep(state: PullStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
@ -248,6 +248,6 @@ export class PullGitCommand extends QuickCommand {
}
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 6
- 6
src/commands/git/push.ts View File

@ -28,7 +28,7 @@ import {
pickRepositoryStep,
QuickCommand,
QuickCommandButtons,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -122,7 +122,7 @@ export class PushGitCommand extends QuickCommand {
context,
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repos = [result];
} else {
@ -132,7 +132,7 @@ export class PushGitCommand extends QuickCommand {
{ skipIfPossible: state.counter >= 1 },
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repos = result;
}
@ -140,7 +140,7 @@ export class PushGitCommand extends QuickCommand {
if (this.confirm(state.confirm)) {
const result = yield* this.confirmStep(state as PushStepState, context);
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -156,7 +156,7 @@ export class PushGitCommand extends QuickCommand {
void this.execute(state as State<Repository[]>);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private async *confirmStep(state: PushStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
@ -412,6 +412,6 @@ export class PushGitCommand extends QuickCommand {
}
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 9
- 8
src/commands/git/rebase.ts View File

@ -15,6 +15,7 @@ import type {
PartialStepState,
QuickPickStep,
StepGenerator,
StepResult,
StepSelection,
StepState,
} from '../quickCommand';
@ -27,7 +28,7 @@ import {
pickRepositoryStep,
QuickCommand,
QuickCommandButtons,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -129,7 +130,7 @@ export class RebaseGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -157,7 +158,7 @@ export class RebaseGitCommand extends QuickCommand {
value: context.selectedBranchOrTag == null ? state.reference?.ref : undefined,
additionalButtons: [pickCommitToggle],
});
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -201,13 +202,13 @@ export class RebaseGitCommand extends QuickCommand {
})} onto`,
picked: state.reference?.ref,
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.reference = result;
}
const result = yield* this.confirmStep(state as RebaseStepState, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
@ -215,7 +216,7 @@ export class RebaseGitCommand extends QuickCommand {
void this.execute(state as RebaseStepState);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private async *confirmStep(state: RebaseStepState, context: Context): AsyncStepResultGenerator<Flags[]> {
@ -239,7 +240,7 @@ export class RebaseGitCommand extends QuickCommand {
);
const selection: StepSelection<typeof step> = yield step;
canPickStepContinue(step, state, selection);
return StepResult.Break;
return StepResultBreak;
}
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
@ -262,6 +263,6 @@ export class RebaseGitCommand extends QuickCommand {
],
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 15
- 15
src/commands/git/remote.ts View File

@ -30,7 +30,7 @@ import {
pickRemoteStep,
pickRepositoryStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -196,7 +196,7 @@ export class RemoteGitCommand extends QuickCommand {
const result = yield* this.pickSubcommandStep(state);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.subcommand = result;
}
@ -214,7 +214,7 @@ export class RemoteGitCommand extends QuickCommand {
state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.repo = result;
}
@ -247,7 +247,7 @@ export class RemoteGitCommand extends QuickCommand {
}
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *pickSubcommandStep(state: PartialStepState<State>): StepResultGenerator<State['subcommand']> {
@ -277,7 +277,7 @@ export class RemoteGitCommand extends QuickCommand {
buttons: [QuickInputButtons.Back],
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *addCommandSteps(state: AddStepState, context: Context): AsyncStepResultGenerator<void> {
@ -293,7 +293,7 @@ export class RemoteGitCommand extends QuickCommand {
placeholder: 'Please provide a name for the remote',
value: state.name,
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
alreadyExists = (await state.repo.getRemotes({ filter: r => r.name === result })).length !== 0;
if (alreadyExists) {
@ -309,14 +309,14 @@ export class RemoteGitCommand extends QuickCommand {
placeholder: 'Please provide a URL for the remote',
value: state.url,
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.url = result;
}
if (this.confirm(state.confirm)) {
const result = yield* this.addCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
}
@ -350,7 +350,7 @@ export class RemoteGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *removeCommandSteps(state: RemoveStepState, context: Context): AsyncStepResultGenerator<void> {
@ -374,14 +374,14 @@ export class RemoteGitCommand extends QuickCommand {
placeholder: 'Choose remote to remove',
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.remote = result;
}
assertStateStepRemoveRemotes(state);
const result = yield* this.removeCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
endSteps(state);
try {
@ -408,7 +408,7 @@ export class RemoteGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? undefined : StepResult.Break;
return canPickStepContinue(step, state, selection) ? undefined : StepResultBreak;
}
private async *pruneCommandSteps(state: PruneStepState, context: Context): AsyncStepResultGenerator<void> {
@ -430,14 +430,14 @@ export class RemoteGitCommand extends QuickCommand {
placeholder: 'Choose a remote to prune',
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.remote = result;
}
assertStateStepPruneRemotes(state);
const result = yield* this.pruneCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
endSteps(state);
void state.repo.pruneRemote(state.remote.name);
@ -459,6 +459,6 @@ export class RemoteGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? undefined : StepResult.Break;
return canPickStepContinue(step, state, selection) ? undefined : StepResultBreak;
}
}

+ 7
- 6
src/commands/git/reset.ts View File

@ -11,6 +11,7 @@ import type {
PartialStepState,
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
@ -22,7 +23,7 @@ import {
pickCommitStep,
pickRepositoryStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -109,7 +110,7 @@ export class ResetGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -142,7 +143,7 @@ export class ResetGitCommand extends QuickCommand {
: `Choose a commit to reset ${context.destination.name} to`,
picked: state.reference?.ref,
});
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -156,7 +157,7 @@ export class ResetGitCommand extends QuickCommand {
if (this.confirm(state.confirm)) {
const result = yield* this.confirmStep(state as ResetStepState, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
}
@ -165,7 +166,7 @@ export class ResetGitCommand extends QuickCommand {
this.execute(state as ResetStepState);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *confirmStep(state: ResetStepState, context: Context): StepResultGenerator<Flags[]> {
@ -195,6 +196,6 @@ export class ResetGitCommand extends QuickCommand {
],
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 7
- 6
src/commands/git/revert.ts View File

@ -11,6 +11,7 @@ import type {
PartialStepState,
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
@ -22,7 +23,7 @@ import {
pickCommitsStep,
pickRepositoryStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -115,7 +116,7 @@ export class RevertGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -148,7 +149,7 @@ export class RevertGitCommand extends QuickCommand {
picked: state.references?.map(r => r.ref),
},
);
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -161,7 +162,7 @@ export class RevertGitCommand extends QuickCommand {
}
const result = yield* this.confirmStep(state as RevertStepState, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
@ -169,7 +170,7 @@ export class RevertGitCommand extends QuickCommand {
this.execute(state as RevertStepState<State<GitRevisionReference[]>>);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *confirmStep(state: RevertStepState, context: Context): StepResultGenerator<Flags[]> {
@ -189,6 +190,6 @@ export class RevertGitCommand extends QuickCommand {
],
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 16
- 9
src/commands/git/search.ts View File

@ -14,7 +14,14 @@ import { pluralize } from '../../system/string';
import { SearchResultsNode } from '../../views/nodes/searchResultsNode';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import { getSteps } from '../gitCommands.utils';
import type { PartialStepState, StepGenerator, StepResultGenerator, StepSelection, StepState } from '../quickCommand';
import type {
PartialStepState,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
} from '../quickCommand';
import {
appendReposToTitle,
canPickStepContinue,
@ -24,7 +31,7 @@ import {
pickRepositoryStep,
QuickCommand,
QuickCommandButtons,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -141,7 +148,7 @@ export class SearchGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -149,7 +156,7 @@ export class SearchGitCommand extends QuickCommand {
if (state.counter < 2 || state.query == null) {
const result = yield* this.pickSearchOperatorStep(state as SearchStepState, context);
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -238,7 +245,7 @@ export class SearchGitCommand extends QuickCommand {
),
},
});
if (result === StepResult.Break) {
if (result === StepResultBreak) {
state.counter--;
continue;
}
@ -252,7 +259,7 @@ export class SearchGitCommand extends QuickCommand {
pin: false,
preserveFocus: false,
});
result = StepResult.Break;
result = StepResultBreak;
} else {
result = yield* getSteps(
this.container,
@ -268,12 +275,12 @@ export class SearchGitCommand extends QuickCommand {
}
state.counter--;
if (result === StepResult.Break) {
if (result === StepResultBreak) {
endSteps(state);
}
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *pickSearchOperatorStep(state: SearchStepState, context: Context): StepResultGenerator<string> {
@ -392,7 +399,7 @@ export class SearchGitCommand extends QuickCommand {
if (!canPickStepContinue(step, state, selection)) {
// Since we simulated a step above, we need to remove it here
state.counter--;
return StepResult.Break;
return StepResultBreak;
}
// Since we simulated a step above, we need to remove it here

+ 10
- 9
src/commands/git/show.ts View File

@ -8,14 +8,15 @@ import { CommandQuickPickItem } from '../../quickpicks/items/common';
import { GitCommandQuickPickItem } from '../../quickpicks/items/gitCommands';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type { PartialStepState, StepGenerator } from '../quickCommand';
import { endSteps ,
import {
endSteps,
pickCommitStep,
pickRepositoryStep,
QuickCommand,
showCommitOrStashFilesStep,
showCommitOrStashFileStep,
showCommitOrStashStep,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -127,7 +128,7 @@ export class ShowGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -159,7 +160,7 @@ export class ShowGitCommand extends QuickCommand {
placeholder: 'Enter a reference or commit SHA',
picked: state.reference?.ref,
});
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -180,12 +181,12 @@ export class ShowGitCommand extends QuickCommand {
}
const result = yield* showCommitOrStashStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
if (result instanceof GitCommandQuickPickItem) {
const r = yield* result.executeSteps(this.pickedVia);
state.counter--;
if (r === StepResult.Break) {
if (r === StepResultBreak) {
endSteps(state);
}
@ -204,7 +205,7 @@ export class ShowGitCommand extends QuickCommand {
const result = yield* showCommitOrStashFilesStep(state, context, {
picked: state.fileName,
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
if (result instanceof CommitFilesQuickPickItem) {
// Since this is a sort of toggle button, back up 2 steps
@ -219,7 +220,7 @@ export class ShowGitCommand extends QuickCommand {
assertsStateStepFileName(state);
const result = yield* showCommitOrStashFileStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
if (result instanceof CommitFilesQuickPickItem) {
// Since this is a sort of toggle button, back up 2 steps
@ -243,6 +244,6 @@ export class ShowGitCommand extends QuickCommand {
}
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
}

+ 18
- 17
src/commands/git/stash.ts View File

@ -23,6 +23,7 @@ import type {
PartialStepState,
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
StepSelection,
StepState,
@ -39,7 +40,7 @@ import {
pickStashStep,
QuickCommand,
QuickCommandButtons,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -186,7 +187,7 @@ export class StashGitCommand extends QuickCommand {
const result = yield* this.pickSubcommandStep(state);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.subcommand = result;
}
@ -204,7 +205,7 @@ export class StashGitCommand extends QuickCommand {
state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.repo = result;
}
@ -235,7 +236,7 @@ export class StashGitCommand extends QuickCommand {
}
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *pickSubcommandStep(state: PartialStepState<State>): StepResultGenerator<State['subcommand']> {
@ -279,7 +280,7 @@ export class StashGitCommand extends QuickCommand {
buttons: [QuickInputButtons.Back],
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *applyOrPopCommandSteps(state: ApplyStepState | PopStepState, context: Context): StepGenerator {
@ -294,14 +295,14 @@ export class StashGitCommand extends QuickCommand {
picked: state.reference?.ref,
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.reference = result;
}
if (this.confirm(state.confirm)) {
const result = yield* this.applyOrPopCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.subcommand = result;
}
@ -388,7 +389,7 @@ export class StashGitCommand extends QuickCommand {
},
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *dropCommandSteps(state: DropStepState, context: Context): StepGenerator {
@ -401,13 +402,13 @@ export class StashGitCommand extends QuickCommand {
picked: state.reference?.ref,
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.reference = result;
}
const result = yield* this.dropCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
endSteps(state);
try {
@ -452,7 +453,7 @@ export class StashGitCommand extends QuickCommand {
},
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? undefined : StepResult.Break;
return canPickStepContinue(step, state, selection) ? undefined : StepResultBreak;
}
private async *listCommandSteps(state: ListStepState, context: Context): StepGenerator {
@ -467,7 +468,7 @@ export class StashGitCommand extends QuickCommand {
picked: state.reference?.ref,
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.reference = result;
}
@ -484,7 +485,7 @@ export class StashGitCommand extends QuickCommand {
this.pickedVia,
);
state.counter--;
if (result === StepResult.Break) {
if (result === StepResultBreak) {
endSteps(state);
}
}
@ -504,14 +505,14 @@ export class StashGitCommand extends QuickCommand {
const result = yield* this.pushCommandInputMessageStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.message = result;
}
if (this.confirm(state.confirm)) {
const result = yield* this.pushCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
}
@ -563,7 +564,7 @@ export class StashGitCommand extends QuickCommand {
const value: StepSelection<typeof step> = yield step;
if (!canStepContinue(step, state, value) || !(await canInputStepContinue(step, state, value))) {
return StepResult.Break;
return StepResultBreak;
}
return value;
@ -611,6 +612,6 @@ export class StashGitCommand extends QuickCommand {
{ placeholder: `Confirm ${context.title}` },
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 4
- 4
src/commands/git/status.ts View File

@ -8,7 +8,7 @@ import { GitCommandQuickPickItem } from '../../quickpicks/items/gitCommands';
import { pad } from '../../system/string';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type { PartialStepState, StepGenerator, StepState } from '../quickCommand';
import { endSteps, pickRepositoryStep, QuickCommand, showRepositoryStatusStep, StepResult } from '../quickCommand';
import { endSteps, pickRepositoryStep, QuickCommand, showRepositoryStatusStep, StepResultBreak } from '../quickCommand';
interface Context {
repos: Repository[];
@ -75,7 +75,7 @@ export class StatusGitCommand extends QuickCommand {
} else {
const result = yield* pickRepositoryStep(state, context);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repo = result;
}
@ -96,7 +96,7 @@ export class StatusGitCommand extends QuickCommand {
)}`;
const result = yield* showRepositoryStatusStep(state as StatusStepState, context);
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -108,7 +108,7 @@ export class StatusGitCommand extends QuickCommand {
if (result instanceof GitCommandQuickPickItem) {
const r = yield* result.executeSteps(this.pickedVia);
state.counter--;
if (r === StepResult.Break) {
if (r === StepResultBreak) {
endSteps(state);
}

+ 7
- 7
src/commands/git/switch.ts View File

@ -22,7 +22,7 @@ import {
pickBranchOrTagStepMultiRepo,
pickRepositoriesStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -133,7 +133,7 @@ export class SwitchGitCommand extends QuickCommand {
{ skipIfPossible: state.counter >= 1 },
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.repos = result;
}
@ -143,7 +143,7 @@ export class SwitchGitCommand extends QuickCommand {
const result = yield* pickBranchOrTagStepMultiRepo(state as SwitchStepState, context, {
placeholder: context => `Choose a branch${context.showTags ? ' or tag' : ''} to switch to`,
});
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
state.counter--;
@ -171,7 +171,7 @@ export class SwitchGitCommand extends QuickCommand {
})}`,
value: state.createBranch ?? GitReference.getNameWithoutRemote(state.reference),
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.createBranch = result;
} else {
@ -186,7 +186,7 @@ export class SwitchGitCommand extends QuickCommand {
if (this.confirm(state.confirm || context.switchToLocalFrom != null)) {
const result = yield* this.confirmStep(state as SwitchStepState, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
if (result === 'switch+fast-forward') {
state.fastForwardTo = context.switchToLocalFrom;
@ -197,7 +197,7 @@ export class SwitchGitCommand extends QuickCommand {
void this.execute(state as SwitchStepState);
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *confirmStep(state: SwitchStepState, context: Context): StepResultGenerator<ConfirmationChoice> {
@ -246,6 +246,6 @@ export class SwitchGitCommand extends QuickCommand {
{ placeholder: `Confirm ${context.title}` },
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

+ 14
- 14
src/commands/git/tag.ts View File

@ -32,7 +32,7 @@ import {
pickRepositoryStep,
pickTagsStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -158,7 +158,7 @@ export class TagGitCommand extends QuickCommand {
const result = yield* this.pickSubcommandStep(state);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.subcommand = result;
}
@ -174,7 +174,7 @@ export class TagGitCommand extends QuickCommand {
state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.repo = result;
}
@ -203,7 +203,7 @@ export class TagGitCommand extends QuickCommand {
}
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *pickSubcommandStep(state: PartialStepState<State>): StepResultGenerator<State['subcommand']> {
@ -227,7 +227,7 @@ export class TagGitCommand extends QuickCommand {
buttons: [QuickInputButtons.Back],
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *createCommandSteps(state: CreateStepState, context: Context): AsyncStepResultGenerator<void> {
@ -245,7 +245,7 @@ export class TagGitCommand extends QuickCommand {
value: GitReference.isRevision(state.reference) ? state.reference.ref : undefined,
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.reference = result;
}
@ -256,14 +256,14 @@ export class TagGitCommand extends QuickCommand {
titleContext: ` at ${GitReference.toString(state.reference, { capitalize: true, icon: false })}`,
value: state.name ?? GitReference.getNameWithoutRemote(state.reference),
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.name = result;
}
if (state.counter < 5 || state.message == null) {
const result = yield* this.createCommandInputMessageStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.message = result;
}
@ -274,7 +274,7 @@ export class TagGitCommand extends QuickCommand {
if (this.confirm(state.confirm)) {
const result = yield* this.createCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
}
@ -307,7 +307,7 @@ export class TagGitCommand extends QuickCommand {
const value: StepSelection<typeof step> = yield step;
if (!canStepContinue(step, state, value) || !(await canInputStepContinue(step, state, value))) {
return StepResult.Break;
return StepResultBreak;
}
return value;
@ -340,7 +340,7 @@ export class TagGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *deleteCommandSteps(state: DeleteStepState, context: Context): StepGenerator {
@ -357,7 +357,7 @@ export class TagGitCommand extends QuickCommand {
placeholder: 'Choose tags to delete',
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.references = result;
}
@ -365,7 +365,7 @@ export class TagGitCommand extends QuickCommand {
context.title = getTitle(pluralize('Tag', state.references.length, { only: true }), state.subcommand);
const result = yield* this.deleteCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
endSteps(state);
state.repo.tagDelete(state.references);
@ -387,6 +387,6 @@ export class TagGitCommand extends QuickCommand {
context,
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? undefined : StepResult.Break;
return canPickStepContinue(step, state, selection) ? undefined : StepResultBreak;
}
}

+ 18
- 18
src/commands/git/worktree.ts View File

@ -50,7 +50,7 @@ import {
pickWorktreesStep,
pickWorktreeStep,
QuickCommand,
StepResult,
StepResultBreak,
} from '../quickCommand';
interface Context {
@ -195,7 +195,7 @@ export class WorktreeGitCommand extends QuickCommand {
const result = yield* this.pickSubcommandStep(state);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.subcommand = result;
}
@ -211,7 +211,7 @@ export class WorktreeGitCommand extends QuickCommand {
state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.repo = result;
}
@ -221,7 +221,7 @@ export class WorktreeGitCommand extends QuickCommand {
state.repo = await state.repo.getMainRepository();
const result = yield* ensureAccessStep(state as any, context, PlusFeatures.Worktrees);
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
context.title = getTitle(state.subcommand === 'delete' ? 'Worktrees' : this.title, state.subcommand);
@ -255,7 +255,7 @@ export class WorktreeGitCommand extends QuickCommand {
}
}
return state.counter < 0 ? StepResult.Break : undefined;
return state.counter < 0 ? StepResultBreak : undefined;
}
private *pickSubcommandStep(state: PartialStepState<State>): StepResultGenerator<State['subcommand']> {
@ -285,7 +285,7 @@ export class WorktreeGitCommand extends QuickCommand {
buttons: [QuickInputButtons.Back],
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *createCommandSteps(state: CreateStepState, context: Context): AsyncStepResultGenerator<void> {
@ -313,7 +313,7 @@ export class WorktreeGitCommand extends QuickCommand {
value: GitReference.isRevision(state.reference) ? state.reference.ref : undefined,
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.reference = result;
}
@ -334,7 +334,7 @@ export class WorktreeGitCommand extends QuickCommand {
})}`,
defaultUri: context.defaultUri,
});
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.uri = result;
// Keep track of the actual uri they picked, because we will modify it in later steps
@ -344,7 +344,7 @@ export class WorktreeGitCommand extends QuickCommand {
if (this.confirm(state.confirm)) {
const result = yield* this.createCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
[state.uri, state.flags] = result;
}
@ -369,7 +369,7 @@ export class WorktreeGitCommand extends QuickCommand {
})}`,
value: state.createBranch ?? GitReference.getNameWithoutRemote(state.reference),
});
if (result === StepResult.Break) {
if (result === StepResultBreak) {
// Clear the flags, since we can backup after the confirm step below (which is non-standard)
state.flags = [];
continue;
@ -534,7 +534,7 @@ export class WorktreeGitCommand extends QuickCommand {
const value: StepSelection<typeof step> = yield step;
if (!canStepContinue(step, state, value) || !(await canInputStepContinue(step, state, value))) {
return StepResult.Break;
return StepResultBreak;
}
return value;
@ -656,7 +656,7 @@ export class WorktreeGitCommand extends QuickCommand {
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection)
? [selection[0].context, selection[0].item]
: StepResult.Break;
: StepResultBreak;
}
private async *deleteCommandSteps(state: DeleteStepState, context: Context): StepGenerator {
@ -677,7 +677,7 @@ export class WorktreeGitCommand extends QuickCommand {
placeholder: 'Choose worktrees to delete',
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.uris = result.map(w => w.uri);
}
@ -685,7 +685,7 @@ export class WorktreeGitCommand extends QuickCommand {
context.title = getTitle(pluralize('Worktree', state.uris.length, { only: true }), state.subcommand);
const result = yield* this.deleteCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
@ -770,7 +770,7 @@ export class WorktreeGitCommand extends QuickCommand {
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
private async *openCommandSteps(state: OpenStepState, context: Context): StepGenerator {
@ -790,7 +790,7 @@ export class WorktreeGitCommand extends QuickCommand {
placeholder: 'Choose worktree to open',
});
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;
if (result === StepResultBreak) break;
state.uri = result.uri;
}
@ -798,7 +798,7 @@ export class WorktreeGitCommand extends QuickCommand {
context.title = getTitle('Worktree', state.subcommand);
const result = yield* this.openCommandConfirmStep(state, context);
if (result === StepResult.Break) continue;
if (result === StepResultBreak) continue;
state.flags = result;
@ -844,6 +844,6 @@ export class WorktreeGitCommand extends QuickCommand {
);
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
}

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

@ -32,7 +32,7 @@ import type { TagGitCommandArgs } from './git/tag';
import type { WorktreeGitCommandArgs } from './git/worktree';
import { PickCommandStep } from './gitCommands.utils';
import type { CustomStep, QuickCommand, QuickInputStep, QuickPickStep, StepSelection } from './quickCommand';
import { isCustomStep , isQuickCommand, isQuickInputStep, isQuickPickStep, StepResult } from './quickCommand';
import { isCustomStep, isQuickCommand, isQuickInputStep, isQuickPickStep, StepResultBreak } from './quickCommand';
import { QuickCommandButtons, ToggleQuickInputButton } from './quickCommand.buttons';
const sanitizeLabel = /\$\(.+?\)|\s/g;
@ -293,7 +293,7 @@ export class GitCommandsCommand extends Command {
private async showCustomStep(step: CustomStep, commandsStep: PickCommandStep) {
const result = await step.show(step);
if (result === StepResult.Break) return undefined;
if (result === StepResultBreak) return undefined;
if (isDirective(result)) {
switch (result) {

+ 26
- 26
src/commands/quickCommand.steps.ts View File

@ -107,7 +107,7 @@ import {
createPickStep,
endSteps,
QuickCommandButtons,
StepResult,
StepResultBreak,
} from './quickCommand';
export function appendReposToTitle<
@ -525,7 +525,7 @@ export async function* inputBranchNameStep<
const value: StepSelection<typeof step> = yield step;
if (!canStepContinue(step, state, value) || !(await canInputStepContinue(step, state, value))) {
return StepResult.Break;
return StepResultBreak;
}
return value;
@ -566,7 +566,7 @@ export async function* inputRemoteNameStep<
const value: StepSelection<typeof step> = yield step;
if (!canStepContinue(step, state, value) || !(await canInputStepContinue(step, state, value))) {
return StepResult.Break;
return StepResultBreak;
}
return value;
@ -598,7 +598,7 @@ export async function* inputRemoteUrlStep<
const value: StepSelection<typeof step> = yield step;
if (!canStepContinue(step, state, value) || !(await canInputStepContinue(step, state, value))) {
return StepResult.Break;
return StepResultBreak;
}
return value;
@ -643,7 +643,7 @@ export async function* inputTagNameStep<
const value: StepSelection<typeof step> = yield step;
if (!canStepContinue(step, state, value) || !(await canInputStepContinue(step, state, value))) {
return StepResult.Break;
return StepResultBreak;
}
return value;
@ -698,7 +698,7 @@ export async function* pickBranchStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
export async function* pickBranchesStep<
@ -754,7 +754,7 @@ export async function* pickBranchesStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResultBreak;
}
export async function* pickBranchOrTagStep<
@ -869,7 +869,7 @@ export async function* pickBranchOrTagStep<
onValidateValue: getValidateGitReferenceFn(state.repo, { ranges: ranges }),
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
export async function* pickBranchOrTagStepMultiRepo<
@ -983,7 +983,7 @@ export async function* pickBranchOrTagStepMultiRepo<
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
export async function* pickCommitStep<
@ -1108,13 +1108,13 @@ export async function* pickCommitStep<
}),
});
const selection: StepSelection<typeof step> = yield step;
if (!canPickStepContinue(step, state, selection)) return StepResult.Break;
if (!canPickStepContinue(step, state, selection)) return StepResultBreak;
if (CommandQuickPickItem.is(selection[0])) {
endSteps(state);
await selection[0].execute();
return StepResult.Break;
return StepResultBreak;
}
return selection[0].item;
@ -1212,7 +1212,7 @@ export function* pickCommitsStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResultBreak;
}
export async function* pickContributorsStep<
@ -1253,7 +1253,7 @@ export async function* pickContributorsStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResultBreak;
}
export async function* pickRemoteStep<
@ -1305,7 +1305,7 @@ export async function* pickRemoteStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
export async function* pickRemotesStep<
@ -1358,7 +1358,7 @@ export async function* pickRemotesStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResultBreak;
}
export async function* pickRepositoryStep<
@ -1408,7 +1408,7 @@ export async function* pickRepositoryStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
export async function* pickRepositoriesStep<
@ -1478,7 +1478,7 @@ export async function* pickRepositoriesStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResultBreak;
}
export function* pickStashStep<
@ -1537,7 +1537,7 @@ export function* pickStashStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
export async function* pickTagsStep<
@ -1594,7 +1594,7 @@ export async function* pickTagsStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResultBreak;
}
export async function* pickWorktreeStep<
@ -1654,7 +1654,7 @@ export async function* pickWorktreeStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0].item : StepResultBreak;
}
export async function* pickWorktreesStep<
@ -1715,7 +1715,7 @@ export async function* pickWorktreesStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection.map(i => i.item) : StepResultBreak;
}
export async function* showCommitOrStashStep<
@ -1776,7 +1776,7 @@ export async function* showCommitOrStashStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0] : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0] : StepResultBreak;
}
async function getShowCommitOrStashStepItems<
@ -2060,7 +2060,7 @@ export function* showCommitOrStashFilesStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0] : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0] : StepResultBreak;
}
export async function* showCommitOrStashFileStep<
@ -2127,7 +2127,7 @@ export async function* showCommitOrStashFileStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0] : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0] : StepResultBreak;
}
async function getShowCommitOrStashFileStepItems<
@ -2252,7 +2252,7 @@ export function* showRepositoryStatusStep<
},
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? selection[0] : StepResult.Break;
return canPickStepContinue(step, state, selection) ? selection[0] : StepResultBreak;
}
function getShowRepositoryStatusStepItems<
@ -2419,5 +2419,5 @@ export async function* ensureAccessStep<
});
const selection: StepSelection<typeof step> = yield step;
return canPickStepContinue(step, state, selection) ? undefined : StepResult.Break;
return canPickStepContinue(step, state, selection) ? undefined : StepResultBreak;
}

+ 7
- 9
src/commands/quickCommand.ts View File

@ -15,7 +15,7 @@ export interface CustomStep {
}
export function isCustomStep(
step: QuickPickStep | QuickInputStep | CustomStep | typeof StepResult.Break,
step: QuickPickStep | QuickInputStep | CustomStep | typeof StepResultBreak,
): step is CustomStep {
return typeof step === 'object' && (step as CustomStep).show != null;
}
@ -36,7 +36,7 @@ export interface QuickInputStep {
}
export function isQuickInputStep(
step: QuickPickStep | QuickInputStep | typeof StepResult.Break,
step: QuickPickStep | QuickInputStep | typeof StepResultBreak,
): step is QuickInputStep {
return typeof step === 'object' && (step as QuickPickStep).items == null && (step as CustomStep).show == null;
}
@ -75,7 +75,7 @@ export interface QuickPickStep {
}
export function isQuickPickStep(
step: QuickPickStep | QuickInputStep | CustomStep | typeof StepResult.Break,
step: QuickPickStep | QuickInputStep | CustomStep | typeof StepResultBreak,
): step is QuickPickStep {
return typeof step === 'object' && (step as QuickPickStep).items != null;
}
@ -92,10 +92,8 @@ export type StepItemType = T extends CustomStep
? string
: never;
export type StepNavigationKeys = Exclude<Keys, 'left' | 'alt+left' | 'ctrl+left'>;
export namespace StepResult {
export const Break = Symbol('BreakStep');
}
export type StepResult<T> = typeof StepResult.Break | T;
export const StepResultBreak = Symbol('BreakStep');
export type StepResult<T> = typeof StepResultBreak | T;
export type StepResultGenerator<T> = Generator<
QuickPickStep | QuickInputStep | CustomStep,
StepResult<T>,
@ -219,12 +217,12 @@ export abstract class QuickCommand implements QuickPickItem {
this._stepsIterator = undefined;
}
if (result.value === StepResult.Break) {
if (result.value === StepResultBreak) {
this._currentStep = undefined;
return { ...result, value: undefined };
}
this._currentStep = result.value as Exclude<typeof result.value, void | typeof StepResult.Break>;
this._currentStep = result.value as Exclude<typeof result.value, void | typeof StepResultBreak>;
return result;
}

Loading…
Cancel
Save