Bläddra i källkod

Removes FlagsQuickPickItem namespace

main
Eric Amodio 1 år sedan
förälder
incheckning
58fca86256
14 ändrade filer med 100 tillägg och 82 borttagningar
  1. +9
    -8
      src/commands/git/branch.ts
  2. +5
    -4
      src/commands/git/cherry-pick.ts
  3. +7
    -6
      src/commands/git/fetch.ts
  4. +7
    -6
      src/commands/git/merge.ts
  5. +7
    -6
      src/commands/git/pull.ts
  6. +10
    -9
      src/commands/git/push.ts
  7. +4
    -3
      src/commands/git/rebase.ts
  8. +4
    -3
      src/commands/git/remote.ts
  9. +5
    -4
      src/commands/git/reset.ts
  10. +4
    -3
      src/commands/git/revert.ts
  11. +7
    -6
      src/commands/git/stash.ts
  12. +4
    -3
      src/commands/git/tag.ts
  13. +11
    -10
      src/commands/git/worktree.ts
  14. +16
    -11
      src/quickpicks/items/flags.ts

+ 9
- 8
src/commands/git/branch.ts Visa fil

@ -4,7 +4,8 @@ import type { GitBranchReference } from '../../git/models/reference';
import { GitReference } from '../../git/models/reference';
import { Repository } from '../../git/models/repository';
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type {
@ -343,13 +344,13 @@ export class BranchGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<CreateFlags>> = QuickCommand.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<CreateFlags>(state.flags, [], {
createFlagsQuickPickItem<CreateFlags>(state.flags, [], {
label: context.title,
detail: `Will create a new branch named ${state.name} from ${GitReference.toString(
state.reference,
)}`,
}),
FlagsQuickPickItem.create<CreateFlags>(state.flags, ['--switch'], {
createFlagsQuickPickItem<CreateFlags>(state.flags, ['--switch'], {
label: `${context.title} and Switch`,
description: '--switch',
detail: `Will create and switch to a new branch named ${state.name} from ${GitReference.toString(
@ -416,14 +417,14 @@ export class BranchGitCommand extends QuickCommand {
context: Context,
): StepResultGenerator<DeleteFlags[]> {
const confirmations: FlagsQuickPickItem<DeleteFlags>[] = [
FlagsQuickPickItem.create<DeleteFlags>(state.flags, [], {
createFlagsQuickPickItem<DeleteFlags>(state.flags, [], {
label: context.title,
detail: `Will delete ${GitReference.toString(state.references)}`,
}),
];
if (!state.references.every(b => b.remote)) {
confirmations.push(
FlagsQuickPickItem.create<DeleteFlags>(state.flags, ['--force'], {
createFlagsQuickPickItem<DeleteFlags>(state.flags, ['--force'], {
label: `Force ${context.title}`,
description: '--force',
detail: `Will forcibly delete ${GitReference.toString(state.references)}`,
@ -432,7 +433,7 @@ export class BranchGitCommand extends QuickCommand {
if (state.references.some(b => b.upstream != null)) {
confirmations.push(
FlagsQuickPickItem.create<DeleteFlags>(state.flags, ['--remotes'], {
createFlagsQuickPickItem<DeleteFlags>(state.flags, ['--remotes'], {
label: `${context.title} & Remote${
state.references.filter(b => !b.remote).length > 1 ? 's' : ''
}`,
@ -441,7 +442,7 @@ export class BranchGitCommand extends QuickCommand {
state.references,
)} and any remote tracking branches`,
}),
FlagsQuickPickItem.create<DeleteFlags>(state.flags, ['--force', '--remotes'], {
createFlagsQuickPickItem<DeleteFlags>(state.flags, ['--force', '--remotes'], {
label: `Force ${context.title} & Remote${
state.references.filter(b => !b.remote).length > 1 ? 's' : ''
}`,
@ -511,7 +512,7 @@ export class BranchGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<RenameFlags>> = QuickCommand.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<RenameFlags>(state.flags, ['-m'], {
createFlagsQuickPickItem<RenameFlags>(state.flags, ['-m'], {
label: context.title,
detail: `Will rename ${GitReference.toString(state.reference)} to ${state.name}`,
}),

+ 5
- 4
src/commands/git/cherry-pick.ts Visa fil

@ -3,7 +3,8 @@ import type { GitBranch } from '../../git/models/branch';
import type { GitLog } from '../../git/models/log';
import { GitReference, GitRevision } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type {
PartialStepState,
@ -213,20 +214,20 @@ export class CherryPickGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = QuickCommand.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will apply ${GitReference.toString(state.references)} to ${GitReference.toString(
context.destination,
)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--edit'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--edit'], {
label: `${this.title} & Edit`,
description: '--edit',
detail: `Will edit and apply ${GitReference.toString(state.references)} to ${GitReference.toString(
context.destination,
)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--no-commit'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--no-commit'], {
label: `${this.title} without Committing`,
description: '--no-commit',
detail: `Will apply ${GitReference.toString(state.references)} to ${GitReference.toString(

+ 7
- 6
src/commands/git/fetch.ts Visa fil

@ -3,7 +3,8 @@ import type { Container } from '../../container';
import type { GitBranchReference } from '../../git/models/reference';
import { GitReference } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { isStringArray } from '../../system/array';
import { fromNow } from '../../system/date';
import { pad } from '../../system/string';
@ -143,7 +144,7 @@ export class FetchGitCommand extends QuickCommand {
step = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context, lastFetchedOn),
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will fetch ${GitReference.toString(state.reference)}`,
}),
@ -158,21 +159,21 @@ export class FetchGitCommand extends QuickCommand {
step = QuickCommand.createConfirmStep(
appendReposToTitle(`Confirm ${this.title}`, state, context, lastFetchedOn),
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will fetch ${reposToFetch}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--prune'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--prune'], {
label: `${this.title} & Prune`,
description: '--prune',
detail: `Will fetch and prune ${reposToFetch}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--all'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--all'], {
label: `${this.title} All`,
description: '--all',
detail: `Will fetch all remotes of ${reposToFetch}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--all', '--prune'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--all', '--prune'], {
label: `${this.title} All & Prune`,
description: '--all --prune',
detail: `Will fetch and prune all remotes of ${reposToFetch}`,

+ 7
- 6
src/commands/git/merge.ts Visa fil

@ -4,7 +4,8 @@ import type { GitLog } from '../../git/models/log';
import { GitReference, GitRevision } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type {
@ -229,27 +230,27 @@ export class MergeGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will merge ${pluralize('commit', count)} from ${GitReference.toString(
state.reference,
)} into ${GitReference.toString(context.destination)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--ff-only'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--ff-only'], {
label: `Fast-forward ${this.title}`,
description: '--ff-only',
detail: `Will fast-forward merge ${pluralize('commit', count)} from ${GitReference.toString(
state.reference,
)} into ${GitReference.toString(context.destination)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--squash'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--squash'], {
label: `Squash ${this.title}`,
description: '--squash',
detail: `Will squash ${pluralize('commit', count)} from ${GitReference.toString(
state.reference,
)} into one when merging into ${GitReference.toString(context.destination)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--no-ff'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--no-ff'], {
label: `${this.title} without Fast-Forwarding`,
description: '--no-ff',
detail: `Will create a merge commit when merging ${pluralize(
@ -259,7 +260,7 @@ export class MergeGitCommand extends QuickCommand {
context.destination,
)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--no-ff', '--no-commit'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--no-ff', '--no-commit'], {
label: `${this.title} without Fast-Forwarding or Committing`,
description: '--no-ff --no-commit',
detail: `Will merge ${pluralize('commit', count)} from ${GitReference.toString(

+ 7
- 6
src/commands/git/pull.ts Visa fil

@ -5,7 +5,8 @@ import type { GitBranchReference } from '../../git/models/reference';
import { GitReference } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { isStringArray } from '../../system/array';
import { fromNow } from '../../system/date';
import { pad, pluralize } from '../../system/string';
@ -146,11 +147,11 @@ export class PullGitCommand extends QuickCommand {
if (state.repos.length > 1) {
step = this.createConfirmStep(appendReposToTitle(`Confirm ${context.title}`, state, context), [
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will pull ${state.repos.length} repositories`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--rebase'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--rebase'], {
label: `${this.title} with Rebase`,
description: '--rebase',
detail: `Will pull ${state.repos.length} repositories by rebasing`,
@ -181,7 +182,7 @@ export class PullGitCommand extends QuickCommand {
);
} else {
step = this.createConfirmStep(appendReposToTitle(`Confirm ${context.title}`, state, context), [
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will pull${
branch.state.behind
@ -211,11 +212,11 @@ export class PullGitCommand extends QuickCommand {
step = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context, lastFetchedOn),
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will pull${pullDetails}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--rebase'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--rebase'], {
label: `${this.title} with Rebase`,
description: '--rebase',
detail: `Will pull and rebase${pullDetails}`,

+ 10
- 9
src/commands/git/push.ts Visa fil

@ -6,7 +6,8 @@ import type { GitBranchReference } from '../../git/models/reference';
import { GitReference } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { isStringArray } from '../../system/array';
import { fromNow } from '../../system/date';
import { pad, pluralize } from '../../system/string';
@ -163,11 +164,11 @@ export class PushGitCommand extends QuickCommand {
if (state.repos.length > 1) {
step = this.createConfirmStep(appendReposToTitle(`Confirm ${context.title}`, state, context), [
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will push ${state.repos.length} repositories`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--force'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--force'], {
label: `Force ${this.title}${useForceWithLease ? ' (with lease)' : ''}`,
description: `--force${useForceWithLease ? '-with-lease' : ''}`,
detail: `Will force push${useForceWithLease ? ' (with lease)' : ''} ${
@ -196,7 +197,7 @@ export class PushGitCommand extends QuickCommand {
if (branch != null && branch?.upstream == null) {
for (const remote of await repo.getRemotes()) {
items.push(
FlagsQuickPickItem.create<Flags>(
createFlagsQuickPickItem<Flags>(
state.flags,
['--set-upstream', remote.name, branch.name],
{
@ -229,7 +230,7 @@ export class PushGitCommand extends QuickCommand {
step = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<Flags>(state.flags, ['--force'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--force'], {
label: `Force ${this.title}${useForceWithLease ? ' (with lease)' : ''}`,
description: `--force${useForceWithLease ? '-with-lease' : ''}`,
detail: `Will force push${useForceWithLease ? ' (with lease)' : ''} ${
@ -252,7 +253,7 @@ export class PushGitCommand extends QuickCommand {
);
} else if (branch != null && branch?.state.ahead > 0) {
step = this.createConfirmStep(appendReposToTitle(`Confirm ${context.title}`, state, context), [
FlagsQuickPickItem.create<Flags>(state.flags, [branch.getRemoteName()!], {
createFlagsQuickPickItem<Flags>(state.flags, [branch.getRemoteName()!], {
label: this.title,
detail: `Will push ${pluralize(
'commit',
@ -288,7 +289,7 @@ export class PushGitCommand extends QuickCommand {
for (const remote of await repo.getRemotes()) {
items.push(
FlagsQuickPickItem.create<Flags>(
createFlagsQuickPickItem<Flags>(
state.flags,
['--set-upstream', remote.name, status.branch],
{
@ -358,12 +359,12 @@ export class PushGitCommand extends QuickCommand {
...(status?.state.behind
? []
: [
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will push${pushDetails}`,
}),
]),
FlagsQuickPickItem.create<Flags>(state.flags, ['--force'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--force'], {
label: `Force ${this.title}${useForceWithLease ? ' (with lease)' : ''}`,
description: `--force${useForceWithLease ? '-with-lease' : ''}`,
detail: `Will force push${useForceWithLease ? ' (with lease)' : ''} ${pushDetails}${

+ 4
- 3
src/commands/git/rebase.ts Visa fil

@ -4,7 +4,8 @@ import type { GitLog } from '../../git/models/log';
import { GitReference, GitRevision } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { Directive, DirectiveQuickPickItem } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import { getEditorCommand } from '../../system/utils';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
@ -241,14 +242,14 @@ export class RebaseGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will update ${GitReference.toString(context.destination)} by applying ${pluralize(
'commit',
count,
)} on top of ${GitReference.toString(state.reference)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--interactive'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--interactive'], {
label: `Interactive ${this.title}`,
description: '--interactive',
detail: `Will interactively update ${GitReference.toString(

+ 4
- 3
src/commands/git/remote.ts Visa fil

@ -7,7 +7,8 @@ import { Repository } from '../../git/models/repository';
import { Logger } from '../../logger';
import { showGenericErrorMessage } from '../../messages';
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type {
AsyncStepResultGenerator,
@ -332,11 +333,11 @@ export class RemoteGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<AddFlags>> = QuickCommand.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<AddFlags>(state.flags, [], {
createFlagsQuickPickItem<AddFlags>(state.flags, [], {
label: context.title,
detail: `Will add remote '${state.name}' for ${state.url}`,
}),
FlagsQuickPickItem.create<AddFlags>(state.flags, ['-f'], {
createFlagsQuickPickItem<AddFlags>(state.flags, ['-f'], {
label: `${context.title} and Fetch`,
description: '-f',
detail: `Will add and fetch remote '${state.name}' for ${state.url}`,

+ 5
- 4
src/commands/git/reset.ts Visa fil

@ -4,7 +4,8 @@ import type { GitLog } from '../../git/models/log';
import type { GitRevisionReference } from '../../git/models/reference';
import { GitReference } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type {
PartialStepState,
@ -163,20 +164,20 @@ export class ResetGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<Flags>(state.flags, [], {
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will reset (leaves changes in the working tree) ${GitReference.toString(
context.destination,
)} to ${GitReference.toString(state.reference)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--soft'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--soft'], {
label: `Soft ${this.title}`,
description: '--soft',
detail: `Will soft reset (leaves changes in the index and working tree) ${GitReference.toString(
context.destination,
)} to ${GitReference.toString(state.reference)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--hard'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--hard'], {
label: `Hard ${this.title}`,
description: '--hard',
detail: `Will hard reset (discards all changes) ${GitReference.toString(

+ 4
- 3
src/commands/git/revert.ts Visa fil

@ -4,7 +4,8 @@ import type { GitLog } from '../../git/models/log';
import type { GitRevisionReference } from '../../git/models/reference';
import { GitReference } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type {
PartialStepState,
@ -167,12 +168,12 @@ export class RevertGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<Flags>> = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<Flags>(state.flags, ['--no-edit'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--no-edit'], {
label: this.title,
description: '--no-edit',
detail: `Will revert ${GitReference.toString(state.references)}`,
}),
FlagsQuickPickItem.create<Flags>(state.flags, ['--edit'], {
createFlagsQuickPickItem<Flags>(state.flags, ['--edit'], {
label: `${this.title} & Edit`,
description: '--edit',
detail: `Will revert and edit ${GitReference.toString(state.references)}`,

+ 7
- 6
src/commands/git/stash.ts Visa fil

@ -12,7 +12,8 @@ import type { Repository } from '../../git/models/repository';
import { Logger } from '../../logger';
import { showGenericErrorMessage } from '../../messages';
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { formatPath } from '../../system/formatPath';
import { pad } from '../../system/string';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
@ -570,23 +571,23 @@ export class StashGitCommand extends QuickCommand {
appendReposToTitle(`Confirm ${context.title}`, state, context),
state.uris == null || state.uris.length === 0
? [
FlagsQuickPickItem.create<PushFlags>(state.flags, [], {
createFlagsQuickPickItem<PushFlags>(state.flags, [], {
label: context.title,
detail: 'Will stash uncommitted changes',
}),
FlagsQuickPickItem.create<PushFlags>(state.flags, ['--include-untracked'], {
createFlagsQuickPickItem<PushFlags>(state.flags, ['--include-untracked'], {
label: `${context.title} & Include Untracked`,
description: '--include-untracked',
detail: 'Will stash uncommitted changes, including untracked files',
}),
FlagsQuickPickItem.create<PushFlags>(state.flags, ['--keep-index'], {
createFlagsQuickPickItem<PushFlags>(state.flags, ['--keep-index'], {
label: `${context.title} & Keep Staged`,
description: '--keep-index',
detail: 'Will stash uncommitted changes, but will keep staged files intact',
}),
]
: [
FlagsQuickPickItem.create<PushFlags>(state.flags, [], {
createFlagsQuickPickItem<PushFlags>(state.flags, [], {
label: context.title,
detail: `Will stash changes from ${
state.uris.length === 1
@ -594,7 +595,7 @@ export class StashGitCommand extends QuickCommand {
: `${state.uris.length} files`
}`,
}),
FlagsQuickPickItem.create<PushFlags>(state.flags, ['--keep-index'], {
createFlagsQuickPickItem<PushFlags>(state.flags, ['--keep-index'], {
label: `${context.title} & Keep Staged`,
detail: `Will stash changes from ${
state.uris.length === 1

+ 4
- 3
src/commands/git/tag.ts Visa fil

@ -5,7 +5,8 @@ import type { GitTagReference } from '../../git/models/reference';
import { GitReference } from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { pluralize } from '../../system/string';
import type { ViewsWithRepositoryFolders } from '../../views/viewBase';
import type {
@ -315,12 +316,12 @@ export class TagGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<CreateFlags>> = QuickCommand.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<CreateFlags>(state.flags, state.message.length !== 0 ? ['-m'] : [], {
createFlagsQuickPickItem<CreateFlags>(state.flags, state.message.length !== 0 ? ['-m'] : [], {
label: context.title,
description: state.message.length !== 0 ? '-m' : '',
detail: `Will create a new tag named ${state.name} at ${GitReference.toString(state.reference)}`,
}),
FlagsQuickPickItem.create<CreateFlags>(
createFlagsQuickPickItem<CreateFlags>(
state.flags,
state.message.length !== 0 ? ['--force', '-m'] : ['--force'],
{

+ 11
- 10
src/commands/git/worktree.ts Visa fil

@ -18,7 +18,8 @@ import { showGenericErrorMessage } from '../../messages';
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { QuickPickSeparator } from '../../quickpicks/items/common';
import { Directive } from '../../quickpicks/items/directive';
import { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
import { basename, isDescendent } from '../../system/path';
import { pluralize, truncateLeft } from '../../system/string';
import { OpenWorkspaceLocation } from '../../system/utils';
@ -596,7 +597,7 @@ export class WorktreeGitCommand extends QuickCommand {
context,
),
[
FlagsQuickPickItem.create<CreateFlags, Uri>(
createFlagsQuickPickItem<CreateFlags, Uri>(
state.flags,
[],
{
@ -606,7 +607,7 @@ export class WorktreeGitCommand extends QuickCommand {
},
recommendedRootUri,
),
FlagsQuickPickItem.create<CreateFlags, Uri>(
createFlagsQuickPickItem<CreateFlags, Uri>(
state.flags,
['-b'],
{
@ -621,7 +622,7 @@ export class WorktreeGitCommand extends QuickCommand {
...(canCreateDirectlyInPicked
? [
QuickPickSeparator.create(),
FlagsQuickPickItem.create<CreateFlags, Uri>(
createFlagsQuickPickItem<CreateFlags, Uri>(
state.flags,
['--direct'],
{
@ -631,7 +632,7 @@ export class WorktreeGitCommand extends QuickCommand {
},
pickedUri,
),
FlagsQuickPickItem.create<CreateFlags, Uri>(
createFlagsQuickPickItem<CreateFlags, Uri>(
state.flags,
['-b', '--direct'],
{
@ -745,13 +746,13 @@ export class WorktreeGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<DeleteFlags>> = QuickCommand.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<DeleteFlags>(state.flags, [], {
createFlagsQuickPickItem<DeleteFlags>(state.flags, [], {
label: context.title,
detail: `Will delete ${pluralize('worktree', state.uris.length, {
only: state.uris.length === 1,
})}${state.uris.length === 1 ? ` in $(folder) ${GitWorktree.getFriendlyPath(state.uris[0])}` : ''}`,
}),
FlagsQuickPickItem.create<DeleteFlags>(state.flags, ['--force'], {
createFlagsQuickPickItem<DeleteFlags>(state.flags, ['--force'], {
label: `Force ${context.title}`,
description: 'including ANY UNCOMMITTED changes',
detail: `Will forcibly delete ${pluralize('worktree', state.uris.length, {
@ -816,19 +817,19 @@ export class WorktreeGitCommand extends QuickCommand {
const step: QuickPickStep<FlagsQuickPickItem<OpenFlags>> = QuickCommand.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
[
FlagsQuickPickItem.create<OpenFlags>(state.flags, [], {
createFlagsQuickPickItem<OpenFlags>(state.flags, [], {
label: context.title,
detail: `Will open, in the current window, the worktree in $(folder) ${GitWorktree.getFriendlyPath(
state.uri,
)}`,
}),
FlagsQuickPickItem.create<OpenFlags>(state.flags, ['--new-window'], {
createFlagsQuickPickItem<OpenFlags>(state.flags, ['--new-window'], {
label: `${context.title} in a New Window`,
detail: `Will open, in a new window, the worktree in $(folder) ${GitWorktree.getFriendlyPath(
state.uri,
)}`,
}),
FlagsQuickPickItem.create<OpenFlags>(state.flags, ['--reveal-explorer'], {
createFlagsQuickPickItem<OpenFlags>(state.flags, ['--reveal-explorer'], {
label: `Reveal in File Explorer`,
detail: `Will open, in the File Explorer, the worktree in $(folder) ${GitWorktree.getFriendlyPath(
state.uri,

+ 16
- 11
src/quickpicks/items/flags.ts Visa fil

@ -4,18 +4,23 @@ import type { QuickPickItemOfT } from './common';
export type FlagsQuickPickItem<T, Context = void> = Context extends void
? QuickPickItemOfT<T[]>
: QuickPickItemOfT<T[]> & { context: Context };
export namespace FlagsQuickPickItem {
export function create<T>(flags: T[], item: T[], options: QuickPickItem): FlagsQuickPickItem<T>;
export function create<T, Context>(
flags: T[],
item: T[],
options: QuickPickItem,
context: Context,
): FlagsQuickPickItem<T, Context>;
export function create<T, Context = void>(flags: T[], item: T[], options: QuickPickItem, context?: Context): any {
return { ...options, item: item, picked: hasFlags(flags, item), context: context };
}
export function createFlagsQuickPickItem<T>(flags: T[], item: T[], options: QuickPickItem): FlagsQuickPickItem<T>;
export function createFlagsQuickPickItem<T, Context>(
flags: T[],
item: T[],
options: QuickPickItem,
context: Context,
): FlagsQuickPickItem<T, Context>;
export function createFlagsQuickPickItem<T, Context = void>(
flags: T[],
item: T[],
options: QuickPickItem,
context?: Context,
): any {
return { ...options, item: item, picked: hasFlags(flags, item), context: context };
}
function hasFlags<T>(flags: T[], has?: T | T[]): boolean {
if (has === undefined) {
return flags.length === 0;

Laddar…
Avbryt
Spara