From 5901c2db914b2f9985daff85fc767a899bd776a3 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 4 Sep 2020 03:48:37 -0400 Subject: [PATCH] Fixes Git Commands back tracking in certain cases --- src/commands/git/branch.ts | 7 ++++++- src/commands/git/cherry-pick.ts | 7 ++++++- src/commands/git/coauthors.ts | 7 ++++++- src/commands/git/fetch.ts | 7 ++++++- src/commands/git/log.ts | 7 ++++++- src/commands/git/merge.ts | 7 ++++++- src/commands/git/pull.ts | 7 ++++++- src/commands/git/push.ts | 7 ++++++- src/commands/git/rebase.ts | 7 ++++++- src/commands/git/reset.ts | 7 ++++++- src/commands/git/revert.ts | 7 ++++++- src/commands/git/search.ts | 8 ++++++-- src/commands/git/show.ts | 7 ++++++- src/commands/git/stash.ts | 7 ++++++- src/commands/git/status.ts | 7 ++++++- src/commands/git/switch.ts | 7 ++++++- src/commands/git/tag.ts | 7 ++++++- 17 files changed, 102 insertions(+), 18 deletions(-) diff --git a/src/commands/git/branch.ts b/src/commands/git/branch.ts index 09cfcb0..1d98a96 100644 --- a/src/commands/git/branch.ts +++ b/src/commands/git/branch.ts @@ -152,6 +152,8 @@ export class BranchGitCommand extends QuickCommand { title: this.title, }; + let skippedStepTwo = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -170,8 +172,10 @@ export class BranchGitCommand extends QuickCommand { context.title = getTitle(state.subcommand === 'delete' ? 'Branches' : this.title, state.subcommand); 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++; } state.repo = context.repos[0]; @@ -203,7 +207,8 @@ export class BranchGitCommand extends QuickCommand { } // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepTwo) { + skippedStepTwo = false; state.counter--; } } diff --git a/src/commands/git/cherry-pick.ts b/src/commands/git/cherry-pick.ts index 3f37eb9..fda7c23 100644 --- a/src/commands/git/cherry-pick.ts +++ b/src/commands/git/cherry-pick.ts @@ -96,12 +96,16 @@ export class CherryPickGitCommand extends QuickCommand { state.references = [state.references]; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; 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++; } state.repo = context.repos[0]; @@ -137,7 +141,8 @@ export class CherryPickGitCommand extends QuickCommand { ); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/coauthors.ts b/src/commands/git/coauthors.ts index cdd35de..01837a3 100644 --- a/src/commands/git/coauthors.ts +++ b/src/commands/git/coauthors.ts @@ -115,6 +115,8 @@ export class CoAuthorsGitCommand extends QuickCommand { } } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -124,8 +126,10 @@ export class CoAuthorsGitCommand extends QuickCommand { typeof state.repo === 'string' || !context.repos.includes(state.repo) ) { + skippedStepOne = false; if (context.repos.length === 1) { if (state.repo == null) { + skippedStepOne = true; state.counter++; } state.repo = context.repos[0]; @@ -146,7 +150,8 @@ export class CoAuthorsGitCommand extends QuickCommand { ); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/fetch.ts b/src/commands/git/fetch.ts index 072c94f..c708cd6 100644 --- a/src/commands/git/fetch.ts +++ b/src/commands/git/fetch.ts @@ -74,6 +74,8 @@ export class FetchGitCommand extends QuickCommand { state.repos = [state.repos as any]; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -83,8 +85,10 @@ export class FetchGitCommand extends QuickCommand { state.repos.length === 0 || Arrays.isStringArray(state.repos) ) { + skippedStepOne = false; if (context.repos.length === 1) { if (state.repos == null) { + skippedStepOne = true; state.counter++; } state.repos = [context.repos[0]]; @@ -105,7 +109,8 @@ export class FetchGitCommand extends QuickCommand { const result = yield* this.confirmStep(state as FetchStepState, context); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/log.ts b/src/commands/git/log.ts index 94e3462..4185f84 100644 --- a/src/commands/git/log.ts +++ b/src/commands/git/log.ts @@ -82,12 +82,16 @@ export class LogGitCommand extends QuickCommand { title: this.title, }; + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; 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++; } state.repo = context.repos[0]; @@ -113,7 +117,8 @@ export class LogGitCommand extends QuickCommand { }); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/merge.ts b/src/commands/git/merge.ts index b33b7db..06a19f6 100644 --- a/src/commands/git/merge.ts +++ b/src/commands/git/merge.ts @@ -89,12 +89,16 @@ export class MergeGitCommand extends QuickCommand { state.flags = []; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; 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++; } state.repo = context.repos[0]; @@ -130,7 +134,8 @@ export class MergeGitCommand extends QuickCommand { }); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/pull.ts b/src/commands/git/pull.ts index dae0bc0..5d2cf55 100644 --- a/src/commands/git/pull.ts +++ b/src/commands/git/pull.ts @@ -74,6 +74,8 @@ export class PullGitCommand extends QuickCommand { state.repos = [state.repos as any]; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -83,8 +85,10 @@ export class PullGitCommand extends QuickCommand { state.repos.length === 0 || Arrays.isStringArray(state.repos) ) { + skippedStepOne = false; if (context.repos.length === 1) { if (state.repos == null) { + skippedStepOne = true; state.counter++; } state.repos = [context.repos[0]]; @@ -105,7 +109,8 @@ export class PullGitCommand extends QuickCommand { const result = yield* this.confirmStep(state as PullStepState, context); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/push.ts b/src/commands/git/push.ts index f00b903..f786ffd 100644 --- a/src/commands/git/push.ts +++ b/src/commands/git/push.ts @@ -87,6 +87,8 @@ export class PushGitCommand extends QuickCommand { state.repos = [state.repos as any]; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -96,8 +98,10 @@ export class PushGitCommand extends QuickCommand { state.repos.length === 0 || Arrays.isStringArray(state.repos) ) { + skippedStepOne = false; if (context.repos.length === 1) { if (state.repos == null) { + skippedStepOne = true; state.counter++; } state.repos = [context.repos[0]]; @@ -127,7 +131,8 @@ export class PushGitCommand extends QuickCommand { const result = yield* this.confirmStep(state as PushStepState, context); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/rebase.ts b/src/commands/git/rebase.ts index c503380..5a55d72 100644 --- a/src/commands/git/rebase.ts +++ b/src/commands/git/rebase.ts @@ -90,12 +90,16 @@ export class RebaseGitCommand extends QuickCommand { state.flags = []; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; 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++; } state.repo = context.repos[0]; @@ -131,7 +135,8 @@ export class RebaseGitCommand extends QuickCommand { }); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/reset.ts b/src/commands/git/reset.ts index 46242d5..662e5fc 100644 --- a/src/commands/git/reset.ts +++ b/src/commands/git/reset.ts @@ -78,12 +78,16 @@ export class ResetGitCommand extends QuickCommand { state.flags = []; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; 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++; } state.repo = context.repos[0]; @@ -125,7 +129,8 @@ export class ResetGitCommand extends QuickCommand { }); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/revert.ts b/src/commands/git/revert.ts index f9a48e2..8bbea0e 100644 --- a/src/commands/git/revert.ts +++ b/src/commands/git/revert.ts @@ -80,12 +80,16 @@ export class RevertGitCommand extends QuickCommand { state.references = [state.references]; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; 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++; } state.repo = context.repos[0]; @@ -127,7 +131,8 @@ export class RevertGitCommand extends QuickCommand { ); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/search.ts b/src/commands/git/search.ts index 08255c6..bf4cad7 100644 --- a/src/commands/git/search.ts +++ b/src/commands/git/search.ts @@ -107,6 +107,8 @@ export class SearchGitCommand extends QuickCommand { state.showResultsInView = cfg.showResultsInView; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -116,8 +118,10 @@ export class SearchGitCommand extends QuickCommand { typeof state.repo === 'string' || !context.repos.includes(state.repo) ) { + skippedStepOne = false; if (context.repos.length === 1) { if (state.repo == null) { + skippedStepOne = true; state.counter++; } state.repo = context.repos[0]; @@ -134,8 +138,8 @@ export class SearchGitCommand extends QuickCommand { const result = yield* this.pickSearchOperatorStep(state as SearchStepState, context); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { - state.counter--; + if (skippedStepOne) { + skippedStepOne = false; } state.pattern = undefined; diff --git a/src/commands/git/show.ts b/src/commands/git/show.ts index f7b4a27..d1ffe08 100644 --- a/src/commands/git/show.ts +++ b/src/commands/git/show.ts @@ -80,6 +80,8 @@ export class ShowGitCommand extends QuickCommand { title: this.title, }; + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -89,8 +91,10 @@ export class ShowGitCommand extends QuickCommand { typeof state.repo === 'string' || !context.repos.includes(state.repo) ) { + skippedStepOne = false; if (context.repos.length === 1) { if (state.repo == null) { + skippedStepOne = true; state.counter++; } state.repo = context.repos[0]; @@ -125,7 +129,8 @@ export class ShowGitCommand extends QuickCommand { }); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/stash.ts b/src/commands/git/stash.ts index 9550a24..2fe499a 100644 --- a/src/commands/git/stash.ts +++ b/src/commands/git/stash.ts @@ -147,6 +147,8 @@ export class StashGitCommand extends QuickCommand { title: this.title, }; + let skippedStepTwo = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -165,8 +167,10 @@ export class StashGitCommand extends QuickCommand { context.title = getTitle(this.title, state.subcommand); 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++; } state.repo = context.repos[0]; @@ -198,7 +202,8 @@ export class StashGitCommand extends QuickCommand { } // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepTwo) { + skippedStepTwo = false; state.counter--; } } diff --git a/src/commands/git/status.ts b/src/commands/git/status.ts index 06f6e1b..eb1eecc 100644 --- a/src/commands/git/status.ts +++ b/src/commands/git/status.ts @@ -60,6 +60,8 @@ export class StatusGitCommand extends QuickCommand { title: this.title, }; + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -69,8 +71,10 @@ export class StatusGitCommand extends QuickCommand { typeof state.repo === 'string' || !context.repos.includes(state.repo) ) { + skippedStepOne = false; if (context.repos.length === 1) { if (state.repo == null) { + skippedStepOne = true; state.counter++; } state.repo = context.repos[0]; @@ -98,7 +102,8 @@ export class StatusGitCommand extends QuickCommand { const result = yield* showRepositoryStatusStep(state as StatusStepState, context); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/switch.ts b/src/commands/git/switch.ts index 89becf6..fdd3fc1 100644 --- a/src/commands/git/switch.ts +++ b/src/commands/git/switch.ts @@ -92,6 +92,8 @@ export class SwitchGitCommand extends QuickCommand { state.repos = [state.repos] as string[] | Repository[]; } + let skippedStepOne = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -101,8 +103,10 @@ export class SwitchGitCommand extends QuickCommand { state.repos.length === 0 || Arrays.isStringArray(state.repos) ) { + skippedStepOne = false; if (context.repos.length === 1) { if (state.repos == null) { + skippedStepOne = true; state.counter++; } state.repos = [context.repos[0]]; @@ -125,7 +129,8 @@ export class SwitchGitCommand extends QuickCommand { }); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepOne) { + skippedStepOne = false; state.counter--; } diff --git a/src/commands/git/tag.ts b/src/commands/git/tag.ts index 5a31778..87341a7 100644 --- a/src/commands/git/tag.ts +++ b/src/commands/git/tag.ts @@ -131,6 +131,8 @@ export class TagGitCommand extends QuickCommand { title: this.title, }; + let skippedStepTwo = false; + while (this.canStepsContinue(state)) { context.title = this.title; @@ -147,8 +149,10 @@ export class TagGitCommand extends QuickCommand { this.subcommand = state.subcommand; 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++; } state.repo = context.repos[0]; @@ -178,7 +182,8 @@ export class TagGitCommand extends QuickCommand { } // If we skipped the previous step, make sure we back up past it - if (context.repos.length === 1) { + if (skippedStepTwo) { + skippedStepTwo = false; state.counter--; } }