Skip to content

Commit

Permalink
Cleans up back button on many commands
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Sep 12, 2020
1 parent 0f4adab commit 2f056af
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 109 deletions.
8 changes: 3 additions & 5 deletions src/commands/git/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,9 @@ export class BranchGitCommand extends QuickCommand<State> {
if (state.counter < 2 || state.repo == null || typeof state.repo === 'string') {
skippedStepTwo = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepTwo = true;
state.counter++;
}
skippedStepTwo = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand Down Expand Up @@ -208,7 +207,6 @@ export class BranchGitCommand extends QuickCommand<State> {

// If we skipped the previous step, make sure we back up past it
if (skippedStepTwo) {
skippedStepTwo = false;
state.counter--;
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/cherry-pick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,9 @@ export class CherryPickGitCommand extends QuickCommand<State> {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand Down Expand Up @@ -142,7 +141,6 @@ export class CherryPickGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
15 changes: 4 additions & 11 deletions src/commands/git/coauthors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,12 @@ export class CoAuthorsGitCommand extends QuickCommand<State> {
while (this.canStepsContinue(state)) {
context.title = this.title;

if (
state.counter < 1 ||
state.repo == null ||
typeof state.repo === 'string' ||
!context.repos.includes(state.repo)
) {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand All @@ -151,7 +145,6 @@ export class CoAuthorsGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ export class FetchGitCommand extends QuickCommand<State> {
) {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repos == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repos = [context.repos[0]];
} else {
const result = yield* pickRepositoriesStep(
Expand All @@ -110,7 +109,6 @@ export class FetchGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ export class LogGitCommand extends QuickCommand<State> {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand All @@ -118,7 +117,6 @@ export class LogGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ export class MergeGitCommand extends QuickCommand<State> {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand Down Expand Up @@ -135,7 +134,6 @@ export class MergeGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ export class PullGitCommand extends QuickCommand<State> {
) {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repos == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repos = [context.repos[0]];
} else {
const result = yield* pickRepositoriesStep(
Expand All @@ -115,7 +114,6 @@ export class PullGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ export class PushGitCommand extends QuickCommand<State> {
) {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repos == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repos = [context.repos[0]];
} else if (state.reference != null) {
const result = yield* pickRepositoryStep(state, context);
Expand All @@ -131,7 +130,6 @@ export class PushGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/rebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ export class RebaseGitCommand extends QuickCommand<State> {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand Down Expand Up @@ -136,7 +135,6 @@ export class RebaseGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ export class ResetGitCommand extends QuickCommand<State> {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand Down Expand Up @@ -130,7 +129,6 @@ export class ResetGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/revert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,9 @@ export class RevertGitCommand extends QuickCommand<State> {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand Down Expand Up @@ -132,7 +131,6 @@ export class RevertGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
15 changes: 4 additions & 11 deletions src/commands/git/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,12 @@ export class SearchGitCommand extends QuickCommand<State> {
while (this.canStepsContinue(state)) {
context.title = this.title;

if (
state.counter < 1 ||
state.repo == null ||
typeof state.repo === 'string' ||
!context.repos.includes(state.repo)
) {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand All @@ -139,7 +133,6 @@ export class SearchGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
15 changes: 4 additions & 11 deletions src/commands/git/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,12 @@ export class ShowGitCommand extends QuickCommand<State> {
while (this.canStepsContinue(state)) {
context.title = this.title;

if (
state.counter < 1 ||
state.repo == null ||
typeof state.repo === 'string' ||
!context.repos.includes(state.repo)
) {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand Down Expand Up @@ -130,7 +124,6 @@ export class ShowGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/stash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,9 @@ export class StashGitCommand extends QuickCommand<State> {
if (state.counter < 2 || state.repo == null || typeof state.repo === 'string') {
skippedStepTwo = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepTwo = true;
state.counter++;
}
skippedStepTwo = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand Down Expand Up @@ -203,7 +202,6 @@ export class StashGitCommand extends QuickCommand<State> {

// If we skipped the previous step, make sure we back up past it
if (skippedStepTwo) {
skippedStepTwo = false;
state.counter--;
}
}
Expand Down
15 changes: 4 additions & 11 deletions src/commands/git/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,12 @@ export class StatusGitCommand extends QuickCommand<State> {
while (this.canStepsContinue(state)) {
context.title = this.title;

if (
state.counter < 1 ||
state.repo == null ||
typeof state.repo === 'string' ||
!context.repos.includes(state.repo)
) {
if (state.counter < 1 || state.repo == null || typeof state.repo === 'string') {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repo == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repo = context.repos[0];
} else {
const result = yield* pickRepositoryStep(state, context);
Expand All @@ -103,7 +97,6 @@ export class StatusGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/git/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ export class SwitchGitCommand extends QuickCommand<State> {
) {
skippedStepOne = false;
if (context.repos.length === 1) {
if (state.repos == null) {
skippedStepOne = true;
state.counter++;
}
skippedStepOne = true;
state.counter++;

state.repos = [context.repos[0]];
} else {
const result = yield* pickRepositoriesStep(
Expand All @@ -130,7 +129,6 @@ export class SwitchGitCommand extends QuickCommand<State> {
if (result === StepResult.Break) {
// If we skipped the previous step, make sure we back up past it
if (skippedStepOne) {
skippedStepOne = false;
state.counter--;
}

Expand Down

0 comments on commit 2f056af

Please sign in to comment.