Skip to content

Commit

Permalink
Fixes back button with single repo workspaces
Browse files Browse the repository at this point in the history
Occurs when opened directly with a repo
  • Loading branch information
eamodio committed Sep 11, 2019
1 parent 577b47f commit 13dfa90
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 55 deletions.
11 changes: 6 additions & 5 deletions src/commands/git/cherry-pick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,17 @@ export class CherryPickGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -138,7 +139,7 @@ export class CherryPickGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}

Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ export class FetchGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -149,7 +150,7 @@ export class FetchGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}

Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ export class MergeGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -127,7 +128,7 @@ export class MergeGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}
continue;
Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ export class PullGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -115,7 +116,7 @@ export class PullGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}

Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ export class PushGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -114,7 +115,7 @@ export class PushGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}

Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/rebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,18 @@ export class RebaseGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -163,7 +164,7 @@ export class RebaseGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}
continue;
Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ export class ResetGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -131,7 +132,7 @@ export class ResetGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}
continue;
Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/revert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ export class RevertGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -141,7 +142,7 @@ export class RevertGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}
continue;
Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class SearchGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = this._initialState === undefined ? { counter: 0 } : this._initialState;
let oneRepo = false;
let repos;
let pickedCommit: GitLogCommit | undefined;
let resultsKey: string | undefined;
let resultsPromise: Promise<GitLog | undefined> | undefined;
Expand All @@ -96,11 +96,12 @@ export class SearchGitCommand extends QuickCommandBase<State> {

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 {
Expand Down Expand Up @@ -360,7 +361,7 @@ export class SearchGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}

Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/stash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class StashGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = this._initialState === undefined ? { counter: 0 } : this._initialState;
let oneRepo = false;
let repos;

while (true) {
try {
Expand Down Expand Up @@ -167,11 +167,12 @@ export class StashGitCommand extends QuickCommandBase<State> {

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 {
Expand Down Expand Up @@ -213,7 +214,7 @@ export class StashGitCommand extends QuickCommandBase<State> {
return undefined;
}

if (oneRepo) {
if (repos.length === 1) {
state.counter--;
}
continue;
Expand Down
11 changes: 6 additions & 5 deletions src/commands/git/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,17 @@ export class SwitchGitCommand extends QuickCommandBase<State> {

protected async *steps(): StepAsyncGenerator {
const state: StepState<State> = 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 {
Expand Down Expand Up @@ -171,7 +172,7 @@ export class SwitchGitCommand extends QuickCommandBase<State> {
const selection: StepSelection<typeof step> = yield step;

if (!this.canPickStepMoveNext(step, state, selection)) {
if (oneRepo) {
if (repos.length === 1) {
break;
}

Expand Down

0 comments on commit 13dfa90

Please sign in to comment.