diff --git a/src/commands/git/fetch.ts b/src/commands/git/fetch.ts index 8daaa21..9882d26 100644 --- a/src/commands/git/fetch.ts +++ b/src/commands/git/fetch.ts @@ -59,21 +59,25 @@ export class FetchGitCommand extends QuickCommandBase { state.counter++; state.repos = [repos[0]]; } else { + let actives: Repository[]; + if (state.repos) { + actives = state.repos; + } else { + const active = await Container.git.getActiveRepository(); + actives = active ? [active] : []; + } + const step = this.createPickStep({ multiselect: true, title: this.title, placeholder: 'Choose repositories', items: await Promise.all( repos.map(repo => - RepositoryQuickPickItem.create( - repo, - state.repos ? state.repos.some(r => r.id === repo.id) : undefined, - { - branch: true, - fetched: true, - status: true - } - ) + RepositoryQuickPickItem.create(repo, actives.some(r => r.id === repo.id), { + branch: true, + fetched: true, + status: true + }) ) ) }); diff --git a/src/commands/git/pull.ts b/src/commands/git/pull.ts index 0ea536e..b9dd3ad 100644 --- a/src/commands/git/pull.ts +++ b/src/commands/git/pull.ts @@ -59,21 +59,25 @@ export class PullGitCommand extends QuickCommandBase { state.counter++; state.repos = [repos[0]]; } else { + let actives: Repository[]; + if (state.repos) { + actives = state.repos; + } else { + const active = await Container.git.getActiveRepository(); + actives = active ? [active] : []; + } + const step = this.createPickStep({ multiselect: true, title: this.title, placeholder: 'Choose repositories', items: await Promise.all( repos.map(repo => - RepositoryQuickPickItem.create( - repo, - state.repos ? state.repos.some(r => r.id === repo.id) : undefined, - { - branch: true, - fetched: true, - status: true - } - ) + RepositoryQuickPickItem.create(repo, actives.some(r => r.id === repo.id), { + branch: true, + fetched: true, + status: true + }) ) ) }); diff --git a/src/commands/git/push.ts b/src/commands/git/push.ts index c63f888..4b61263 100644 --- a/src/commands/git/push.ts +++ b/src/commands/git/push.ts @@ -58,21 +58,25 @@ export class PushGitCommand extends QuickCommandBase { state.counter++; state.repos = [repos[0]]; } else { + let actives: Repository[]; + if (state.repos) { + actives = state.repos; + } else { + const active = await Container.git.getActiveRepository(); + actives = active ? [active] : []; + } + const step = this.createPickStep({ multiselect: true, title: this.title, placeholder: 'Choose repositories', items: await Promise.all( repos.map(repo => - RepositoryQuickPickItem.create( - repo, - state.repos ? state.repos.some(r => r.id === repo.id) : undefined, - { - branch: true, - fetched: true, - status: true - } - ) + RepositoryQuickPickItem.create(repo, actives.some(r => r.id === repo.id), { + branch: true, + fetched: true, + status: true + }) ) ) }); diff --git a/src/commands/git/stash.ts b/src/commands/git/stash.ts index afc6a69..30024df 100644 --- a/src/commands/git/stash.ts +++ b/src/commands/git/stash.ts @@ -182,12 +182,14 @@ export class StashGitCommand extends QuickCommandBase { state.counter++; state.repo = repos[0]; } else { + const active = state.repo ? state.repo : await Container.git.getActiveRepository(); + const step = this.createPickStep({ title: `${this.title} ${getSubtitle(state.subcommand)}`, placeholder: 'Choose a repository', items: await Promise.all( repos.map(r => - RepositoryQuickPickItem.create(r, r.id === (state.repo && state.repo.id), { + RepositoryQuickPickItem.create(r, r.id === (active && active.id), { branch: true, fetched: true, status: true diff --git a/src/commands/git/switch.ts b/src/commands/git/switch.ts index 5f2d792..f1ed7eb 100644 --- a/src/commands/git/switch.ts +++ b/src/commands/git/switch.ts @@ -90,17 +90,25 @@ export class SwitchGitCommand extends QuickCommandBase { state.counter++; state.repos = [repos[0]]; } else { + let actives: Repository[]; + if (state.repos) { + actives = state.repos; + } else { + const active = await Container.git.getActiveRepository(); + actives = active ? [active] : []; + } + const step = this.createPickStep({ multiselect: true, title: this.title, placeholder: 'Choose repositories', items: await Promise.all( repos.map(repo => - RepositoryQuickPickItem.create( - repo, - state.repos ? state.repos.some(r => r.id === repo.id) : undefined, - { branch: true, fetched: true, status: true } - ) + RepositoryQuickPickItem.create(repo, actives.some(r => r.id === repo.id), { + branch: true, + fetched: true, + status: true + }) ) ) });