|
@ -48,6 +48,16 @@ interface PushState { |
|
|
type State = ApplyState | DropState | PopState | PushState; |
|
|
type State = ApplyState | DropState | PopState | PushState; |
|
|
type StashStepState<T> = StepState<T> & { repo: Repository }; |
|
|
type StashStepState<T> = StepState<T> & { repo: Repository }; |
|
|
|
|
|
|
|
|
|
|
|
const subcommandToSubtitleMap = new Map<State['subcommand'], string>([ |
|
|
|
|
|
['apply', 'Apply'], |
|
|
|
|
|
['drop', 'Drop'], |
|
|
|
|
|
['pop', 'Pop'], |
|
|
|
|
|
['push', 'Push'] |
|
|
|
|
|
]); |
|
|
|
|
|
function getSubtitle(subcommand: State['subcommand'] | undefined) { |
|
|
|
|
|
return subcommand === undefined ? '' : subcommandToSubtitleMap.get(subcommand); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export interface StashGitCommandArgs { |
|
|
export interface StashGitCommandArgs { |
|
|
readonly command: 'stash'; |
|
|
readonly command: 'stash'; |
|
|
state?: Partial<State>; |
|
|
state?: Partial<State>; |
|
@ -160,7 +170,7 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
state.repo = repos[0]; |
|
|
state.repo = repos[0]; |
|
|
} else { |
|
|
} else { |
|
|
const step = this.createPickStep<RepositoryQuickPickItem>({ |
|
|
const step = this.createPickStep<RepositoryQuickPickItem>({ |
|
|
title: `${this.title} ${state.subcommand}`, |
|
|
|
|
|
|
|
|
title: `${this.title} ${getSubtitle(state.subcommand)}`, |
|
|
placeholder: 'Choose a repository', |
|
|
placeholder: 'Choose a repository', |
|
|
items: await Promise.all( |
|
|
items: await Promise.all( |
|
|
repos.map(r => |
|
|
repos.map(r => |
|
@ -261,7 +271,7 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
const stash = await Container.git.getStashList(state.repo.path); |
|
|
const stash = await Container.git.getStashList(state.repo.path); |
|
|
|
|
|
|
|
|
const step = this.createPickStep<CommitQuickPickItem<GitStashCommit>>({ |
|
|
const step = this.createPickStep<CommitQuickPickItem<GitStashCommit>>({ |
|
|
title: `${this.title} ${state.subcommand}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
|
|
|
|
|
|
title: `${this.title} ${getSubtitle(state.subcommand)}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
state.repo.formattedName |
|
|
state.repo.formattedName |
|
|
}`,
|
|
|
}`,
|
|
|
placeholder: |
|
|
placeholder: |
|
@ -303,12 +313,12 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
: state.stash.message; |
|
|
: state.stash.message; |
|
|
|
|
|
|
|
|
const step = this.createConfirmStep<GitFlagsQuickPickItem & { command: 'apply' | 'pop' }>( |
|
|
const step = this.createConfirmStep<GitFlagsQuickPickItem & { command: 'apply' | 'pop' }>( |
|
|
`Confirm ${this.title} ${state.subcommand}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
|
|
|
|
|
|
`Confirm ${this.title} ${getSubtitle(state.subcommand)}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
state.repo.formattedName |
|
|
state.repo.formattedName |
|
|
}`,
|
|
|
}`,
|
|
|
[ |
|
|
[ |
|
|
{ |
|
|
{ |
|
|
label: `${this.title} ${state.subcommand}`, |
|
|
|
|
|
|
|
|
label: `${this.title} ${getSubtitle(state.subcommand)}`, |
|
|
description: `${state.stash.stashName}${Strings.pad(GlyphChars.Dash, 2, 2)}${message}`, |
|
|
description: `${state.stash.stashName}${Strings.pad(GlyphChars.Dash, 2, 2)}${message}`, |
|
|
detail: |
|
|
detail: |
|
|
state.subcommand === 'pop' |
|
|
state.subcommand === 'pop' |
|
@ -323,7 +333,7 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
}, |
|
|
}, |
|
|
// Alternate confirmation (if pop then apply, and vice versa)
|
|
|
// Alternate confirmation (if pop then apply, and vice versa)
|
|
|
{ |
|
|
{ |
|
|
label: `${this.title} ${state.subcommand === 'pop' ? 'apply' : 'pop'}`, |
|
|
|
|
|
|
|
|
label: `${this.title} ${state.subcommand === 'pop' ? 'Apply' : 'Pop'}`, |
|
|
description: `${state.stash!.stashName}${Strings.pad(GlyphChars.Dash, 2, 2)}${message}`, |
|
|
description: `${state.stash!.stashName}${Strings.pad(GlyphChars.Dash, 2, 2)}${message}`, |
|
|
detail: |
|
|
detail: |
|
|
state.subcommand === 'pop' |
|
|
state.subcommand === 'pop' |
|
@ -337,7 +347,7 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
item: [] |
|
|
item: [] |
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
{ placeholder: `Confirm ${this.title} ${state.subcommand}` } |
|
|
|
|
|
|
|
|
{ placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}` } |
|
|
); |
|
|
); |
|
|
const selection: StepSelection<typeof step> = yield step; |
|
|
const selection: StepSelection<typeof step> = yield step; |
|
|
|
|
|
|
|
@ -365,7 +375,7 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
const stash = await Container.git.getStashList(state.repo.path); |
|
|
const stash = await Container.git.getStashList(state.repo.path); |
|
|
|
|
|
|
|
|
const step = this.createPickStep<CommitQuickPickItem<GitStashCommit>>({ |
|
|
const step = this.createPickStep<CommitQuickPickItem<GitStashCommit>>({ |
|
|
title: `${this.title} ${state.subcommand}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
|
|
|
|
|
|
title: `${this.title} ${getSubtitle(state.subcommand)}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
state.repo.formattedName |
|
|
state.repo.formattedName |
|
|
}`,
|
|
|
}`,
|
|
|
placeholder: |
|
|
placeholder: |
|
@ -405,17 +415,17 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
: state.stash.message; |
|
|
: state.stash.message; |
|
|
|
|
|
|
|
|
const step = this.createConfirmStep<QuickPickItem>( |
|
|
const step = this.createConfirmStep<QuickPickItem>( |
|
|
`Confirm ${this.title} ${state.subcommand}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
|
|
|
|
|
|
`Confirm ${this.title} ${getSubtitle(state.subcommand)}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
state.repo.formattedName |
|
|
state.repo.formattedName |
|
|
}`,
|
|
|
}`,
|
|
|
[ |
|
|
[ |
|
|
{ |
|
|
{ |
|
|
label: `${this.title} ${state.subcommand}`, |
|
|
|
|
|
|
|
|
label: `${this.title} ${getSubtitle(state.subcommand)}`, |
|
|
description: `${state.stash.stashName}${Strings.pad(GlyphChars.Dash, 2, 2)}${message}`, |
|
|
description: `${state.stash.stashName}${Strings.pad(GlyphChars.Dash, 2, 2)}${message}`, |
|
|
detail: `Will delete ${state.stash.stashName}` |
|
|
detail: `Will delete ${state.stash.stashName}` |
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
{ placeholder: `Confirm ${this.title} ${state.subcommand}` } |
|
|
|
|
|
|
|
|
{ placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}` } |
|
|
); |
|
|
); |
|
|
const selection: StepSelection<typeof step> = yield step; |
|
|
const selection: StepSelection<typeof step> = yield step; |
|
|
|
|
|
|
|
@ -436,7 +446,7 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
while (true) { |
|
|
while (true) { |
|
|
if (state.message === undefined || state.counter < 3) { |
|
|
if (state.message === undefined || state.counter < 3) { |
|
|
const step = this.createInputStep({ |
|
|
const step = this.createInputStep({ |
|
|
title: `${this.title} ${state.subcommand}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
|
|
|
|
|
|
title: `${this.title} ${getSubtitle(state.subcommand)}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
state.repo.formattedName |
|
|
state.repo.formattedName |
|
|
}`,
|
|
|
}`,
|
|
|
placeholder: 'Please provide a stash message', |
|
|
placeholder: 'Please provide a stash message', |
|
@ -455,33 +465,33 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
|
|
|
|
|
|
if (this.confirm(state.confirm)) { |
|
|
if (this.confirm(state.confirm)) { |
|
|
const step = this.createConfirmStep<GitFlagsQuickPickItem>( |
|
|
const step = this.createConfirmStep<GitFlagsQuickPickItem>( |
|
|
`Confirm ${this.title} ${state.subcommand}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
|
|
|
|
|
|
`Confirm ${this.title} ${getSubtitle(state.subcommand)}${Strings.pad(GlyphChars.Dot, 2, 2)}${ |
|
|
state.repo.formattedName |
|
|
state.repo.formattedName |
|
|
}`,
|
|
|
}`,
|
|
|
state.uris === undefined || state.uris.length === 0 |
|
|
state.uris === undefined || state.uris.length === 0 |
|
|
? [ |
|
|
? [ |
|
|
{ |
|
|
{ |
|
|
label: `${this.title} ${state.subcommand}`, |
|
|
|
|
|
|
|
|
label: `${this.title} ${getSubtitle(state.subcommand)}`, |
|
|
description: state.message, |
|
|
description: state.message, |
|
|
detail: 'Will stash uncommitted changes', |
|
|
detail: 'Will stash uncommitted changes', |
|
|
item: [] |
|
|
item: [] |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
label: `${this.title} ${state.subcommand}`, |
|
|
|
|
|
description: state.message, |
|
|
|
|
|
|
|
|
label: `${this.title} ${getSubtitle(state.subcommand)} & Include Untracked`, |
|
|
|
|
|
description: `--include-untracked ${state.message}`, |
|
|
detail: 'Will stash uncommitted changes, including untracked files', |
|
|
detail: 'Will stash uncommitted changes, including untracked files', |
|
|
item: ['--include-untracked'] |
|
|
item: ['--include-untracked'] |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
label: `${this.title} ${state.subcommand}`, |
|
|
|
|
|
description: state.message, |
|
|
|
|
|
|
|
|
label: `${this.title} ${getSubtitle(state.subcommand)} & Keep Staged`, |
|
|
|
|
|
description: `--keep-index ${state.message}`, |
|
|
detail: 'Will stash uncommitted changes, but will keep staged files intact', |
|
|
detail: 'Will stash uncommitted changes, but will keep staged files intact', |
|
|
item: ['--keep-index'] |
|
|
item: ['--keep-index'] |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
: [ |
|
|
: [ |
|
|
{ |
|
|
{ |
|
|
label: `${this.title} ${state.subcommand}`, |
|
|
|
|
|
|
|
|
label: `${this.title} ${getSubtitle(state.subcommand)}`, |
|
|
description: state.message, |
|
|
description: state.message, |
|
|
detail: `Will stash changes in ${ |
|
|
detail: `Will stash changes in ${ |
|
|
state.uris.length === 1 |
|
|
state.uris.length === 1 |
|
@ -489,9 +499,19 @@ export class StashGitCommand extends QuickCommandBase { |
|
|
: `${state.uris.length} files` |
|
|
: `${state.uris.length} files` |
|
|
}`,
|
|
|
}`,
|
|
|
item: [] |
|
|
item: [] |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: `${this.title} ${getSubtitle(state.subcommand)} & Keep Staged`, |
|
|
|
|
|
description: `--keep-index ${state.message}`, |
|
|
|
|
|
detail: `Will stash changes in ${ |
|
|
|
|
|
state.uris.length === 1 |
|
|
|
|
|
? GitUri.getFormattedPath(state.uris[0], { relativeTo: state.repo.path }) |
|
|
|
|
|
: `${state.uris.length} files` |
|
|
|
|
|
}, but will keep staged files intact`,
|
|
|
|
|
|
item: ['--keep-index'] |
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
{ placeholder: `Confirm ${this.title} ${state.subcommand}` } |
|
|
|
|
|
|
|
|
{ placeholder: `Confirm ${this.title} ${getSubtitle(state.subcommand)}` } |
|
|
); |
|
|
); |
|
|
const selection: StepSelection<typeof step> = yield step; |
|
|
const selection: StepSelection<typeof step> = yield step; |
|
|
|
|
|
|
|
|