Browse Source

Fixes multiple repos always causing repo prompt

main
Eric Amodio 4 years ago
parent
commit
53308387ef
5 changed files with 15 additions and 2 deletions
  1. +1
    -0
      src/commands/git/fetch.ts
  2. +1
    -0
      src/commands/git/pull.ts
  3. +1
    -0
      src/commands/git/push.ts
  4. +1
    -0
      src/commands/git/switch.ts
  5. +11
    -2
      src/commands/quickCommand.steps.ts

+ 1
- 0
src/commands/git/fetch.ts View File

@ -92,6 +92,7 @@ export class FetchGitCommand extends QuickCommand {
const result = yield* pickRepositoriesStep(
state as ExcludeSome<typeof state, 'repos', string | Repository>,
context,
{ skipIfPossible: state.counter >= 1 },
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;

+ 1
- 0
src/commands/git/pull.ts View File

@ -92,6 +92,7 @@ export class PullGitCommand extends QuickCommand {
const result = yield* pickRepositoriesStep(
state as ExcludeSome<typeof state, 'repos', string | Repository>,
context,
{ skipIfPossible: state.counter >= 1 },
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;

+ 1
- 0
src/commands/git/push.ts View File

@ -114,6 +114,7 @@ export class PushGitCommand extends QuickCommand {
const result = yield* pickRepositoriesStep(
state as ExcludeSome<typeof state, 'repos', string | Repository>,
context,
{ skipIfPossible: state.counter >= 1 },
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;

+ 1
- 0
src/commands/git/switch.ts View File

@ -110,6 +110,7 @@ export class SwitchGitCommand extends QuickCommand {
const result = yield* pickRepositoriesStep(
state as ExcludeSome<typeof state, 'repos', string | Repository>,
context,
{ skipIfPossible: state.counter >= 1 },
);
// Always break on the first step (so we will go back)
if (result === StepResult.Break) break;

+ 11
- 2
src/commands/quickCommand.steps.ts View File

@ -1030,11 +1030,20 @@ export async function* pickRepositoryStep<
export async function* pickRepositoriesStep<
State extends PartialStepState & { repos?: string[] | Repository[] },
Context extends { repos: Repository[]; title: string }
>(state: State, context: Context, placeholder: string = 'Choose repositories'): StepResultGenerator<Repository[]> {
>(
state: State,
context: Context,
options?: { placeholder?: string; skipIfPossible?: boolean },
): StepResultGenerator<Repository[]> {
options = { placeholder: 'Choose repositories', skipIfPossible: false, ...options };
let actives: Repository[];
if (state.repos) {
if (Arrays.isStringArray(state.repos)) {
actives = Arrays.filterMap(state.repos, path => context.repos.find(r => r.path === path));
if (options.skipIfPossible && actives.length !== 0 && state.repos.length === actives.length) {
return actives;
}
} else {
actives = state.repos;
}
@ -1046,7 +1055,7 @@ export async function* pickRepositoriesStep<
const step = QuickCommand.createPickStep<RepositoryQuickPickItem>({
multiselect: true,
title: context.title,
placeholder: placeholder,
placeholder: options.placeholder,
items:
context.repos.length === 0
? [DirectiveQuickPickItem.create(Directive.Cancel)]

Loading…
Cancel
Save