diff --git a/src/commands/git/cherry-pick.ts b/src/commands/git/cherry-pick.ts index dd54ca5..5f846d0 100644 --- a/src/commands/git/cherry-pick.ts +++ b/src/commands/git/cherry-pick.ts @@ -77,16 +77,17 @@ export class CherryPickGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; let selectedBranchOrTag: GitReference | undefined; while (true) { try { - if (state.repo === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repo === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repo = repos[0]; } else { @@ -138,7 +139,7 @@ export class CherryPickGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } diff --git a/src/commands/git/fetch.ts b/src/commands/git/fetch.ts index 628a905..8daaa21 100644 --- a/src/commands/git/fetch.ts +++ b/src/commands/git/fetch.ts @@ -46,15 +46,16 @@ export class FetchGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; while (true) { try { - if (state.repos === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repos === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repos = [repos[0]]; } else { @@ -149,7 +150,7 @@ export class FetchGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } diff --git a/src/commands/git/merge.ts b/src/commands/git/merge.ts index b3207aa..8ad1ccb 100644 --- a/src/commands/git/merge.ts +++ b/src/commands/git/merge.ts @@ -66,15 +66,16 @@ export class MergeGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; while (true) { try { - if (state.repo === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repo === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repo = repos[0]; } else { @@ -127,7 +128,7 @@ export class MergeGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } continue; diff --git a/src/commands/git/pull.ts b/src/commands/git/pull.ts index fa9cc88..0ea536e 100644 --- a/src/commands/git/pull.ts +++ b/src/commands/git/pull.ts @@ -46,15 +46,16 @@ export class PullGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; while (true) { try { - if (state.repos === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repos === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repos = [repos[0]]; } else { @@ -115,7 +116,7 @@ export class PullGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } diff --git a/src/commands/git/push.ts b/src/commands/git/push.ts index d7f79df..c63f888 100644 --- a/src/commands/git/push.ts +++ b/src/commands/git/push.ts @@ -45,15 +45,16 @@ export class PushGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; while (true) { try { - if (state.repos === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repos === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repos = [repos[0]]; } else { @@ -114,7 +115,7 @@ export class PushGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } diff --git a/src/commands/git/rebase.ts b/src/commands/git/rebase.ts index 813033b..3a52eda 100644 --- a/src/commands/git/rebase.ts +++ b/src/commands/git/rebase.ts @@ -70,17 +70,18 @@ export class RebaseGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; let selectedBranchOrTag: GitReference | undefined; let pickCommit = false; while (true) { try { - if (state.repo === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repo === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repo = repos[0]; } else { @@ -163,7 +164,7 @@ export class RebaseGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } continue; diff --git a/src/commands/git/reset.ts b/src/commands/git/reset.ts index 6e56f26..6c37b52 100644 --- a/src/commands/git/reset.ts +++ b/src/commands/git/reset.ts @@ -58,15 +58,16 @@ export class ResetGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; while (true) { try { - if (state.repo === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repo === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repo = repos[0]; } else { @@ -131,7 +132,7 @@ export class ResetGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } continue; diff --git a/src/commands/git/revert.ts b/src/commands/git/revert.ts index 9a83e1d..5ccaf22 100644 --- a/src/commands/git/revert.ts +++ b/src/commands/git/revert.ts @@ -65,15 +65,16 @@ export class RevertGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; while (true) { try { - if (state.repo === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repo === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repo = repos[0]; } else { @@ -141,7 +142,7 @@ export class RevertGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } continue; diff --git a/src/commands/git/search.ts b/src/commands/git/search.ts index b0f3f0b..6f268de 100644 --- a/src/commands/git/search.ts +++ b/src/commands/git/search.ts @@ -75,7 +75,7 @@ export class SearchGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; let pickedCommit: GitLogCommit | undefined; let resultsKey: string | undefined; let resultsPromise: Promise | undefined; @@ -96,11 +96,12 @@ export class SearchGitCommand extends QuickCommandBase { while (true) { try { - if (state.repo === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repo === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repo = repos[0]; } else { @@ -360,7 +361,7 @@ export class SearchGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; } diff --git a/src/commands/git/stash.ts b/src/commands/git/stash.ts index 64c33d1..7bf45ad 100644 --- a/src/commands/git/stash.ts +++ b/src/commands/git/stash.ts @@ -122,7 +122,7 @@ export class StashGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; while (true) { try { @@ -167,11 +167,12 @@ export class StashGitCommand extends QuickCommandBase { this._subcommand = state.subcommand; - if (state.repo === undefined || state.counter < 2) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repo === undefined || state.counter < 2) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repo = repos[0]; } else { @@ -213,7 +214,7 @@ export class StashGitCommand extends QuickCommandBase { return undefined; } - if (oneRepo) { + if (repos.length === 1) { state.counter--; } continue; diff --git a/src/commands/git/switch.ts b/src/commands/git/switch.ts index cc43a22..5f2d792 100644 --- a/src/commands/git/switch.ts +++ b/src/commands/git/switch.ts @@ -76,16 +76,17 @@ export class SwitchGitCommand extends QuickCommandBase { protected async *steps(): StepAsyncGenerator { const state: StepState = this._initialState === undefined ? { counter: 0 } : this._initialState; - let oneRepo = false; + let repos; let showTags = false; while (true) { try { - if (state.repos === undefined || state.counter < 1) { - const repos = [...(await Container.git.getOrderedRepositories())]; + if (repos === undefined) { + repos = [...(await Container.git.getOrderedRepositories())]; + } + if (state.repos === undefined || state.counter < 1) { if (repos.length === 1) { - oneRepo = true; state.counter++; state.repos = [repos[0]]; } else { @@ -171,7 +172,7 @@ export class SwitchGitCommand extends QuickCommandBase { const selection: StepSelection = yield step; if (!this.canPickStepMoveNext(step, state, selection)) { - if (oneRepo) { + if (repos.length === 1) { break; }