Browse Source

Adds active repo selection

main
Eric Amodio 5 years ago
parent
commit
8379fb459a
5 changed files with 55 additions and 33 deletions
  1. +13
    -9
      src/commands/git/fetch.ts
  2. +13
    -9
      src/commands/git/pull.ts
  3. +13
    -9
      src/commands/git/push.ts
  4. +3
    -1
      src/commands/git/stash.ts
  5. +13
    -5
      src/commands/git/switch.ts

+ 13
- 9
src/commands/git/fetch.ts View File

@ -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<RepositoryQuickPickItem>({
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
})
)
)
});

+ 13
- 9
src/commands/git/pull.ts View File

@ -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<RepositoryQuickPickItem>({
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
})
)
)
});

+ 13
- 9
src/commands/git/push.ts View File

@ -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<RepositoryQuickPickItem>({
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
})
)
)
});

+ 3
- 1
src/commands/git/stash.ts View File

@ -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<RepositoryQuickPickItem>({
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

+ 13
- 5
src/commands/git/switch.ts View File

@ -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<RepositoryQuickPickItem>({
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
})
)
)
});

Loading…
Cancel
Save