|
@ -2,10 +2,12 @@ |
|
|
import { InputBoxOptions, Uri, window } from 'vscode'; |
|
|
import { InputBoxOptions, Uri, window } from 'vscode'; |
|
|
import { GlyphChars } from '../constants'; |
|
|
import { GlyphChars } from '../constants'; |
|
|
import { Container } from '../container'; |
|
|
import { Container } from '../container'; |
|
|
|
|
|
import { GitUri } from '../git/gitUri'; |
|
|
import { Logger } from '../logger'; |
|
|
import { Logger } from '../logger'; |
|
|
import { Messages } from '../messages'; |
|
|
import { Messages } from '../messages'; |
|
|
import { CommandQuickPickItem, RepositoriesQuickPick } from '../quickpicks'; |
|
|
|
|
|
import { Command, CommandContext, Commands } from './common'; |
|
|
|
|
|
|
|
|
import { CommandQuickPickItem } from '../quickpicks'; |
|
|
|
|
|
import { StatusFileNode } from '../views/nodes'; |
|
|
|
|
|
import { Command, CommandContext, Commands, getRepoPathOrPrompt } from './common'; |
|
|
|
|
|
|
|
|
export interface StashSaveCommandArgs { |
|
|
export interface StashSaveCommandArgs { |
|
|
message?: string; |
|
|
message?: string; |
|
@ -20,36 +22,35 @@ export class StashSaveCommand extends Command { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected async preExecute(context: CommandContext, args: StashSaveCommandArgs = {}): Promise<any> { |
|
|
protected async preExecute(context: CommandContext, args: StashSaveCommandArgs = {}): Promise<any> { |
|
|
if (context.type === 'scm-states') { |
|
|
|
|
|
|
|
|
if (context.type === 'view') { |
|
|
|
|
|
args = { ...args }; |
|
|
|
|
|
if (context.node instanceof StatusFileNode) { |
|
|
|
|
|
args.uris = [GitUri.fromFile(context.node.file, context.node.repoPath)]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if (context.type === 'scm-states') { |
|
|
args = { ...args }; |
|
|
args = { ...args }; |
|
|
args.uris = context.scmResourceStates.map(s => s.resourceUri); |
|
|
args.uris = context.scmResourceStates.map(s => s.resourceUri); |
|
|
return this.execute(args); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (context.type === 'scm-groups') { |
|
|
|
|
|
|
|
|
else if (context.type === 'scm-groups') { |
|
|
args = { ...args }; |
|
|
args = { ...args }; |
|
|
args.uris = context.scmResourceGroups.reduce<Uri[]>( |
|
|
args.uris = context.scmResourceGroups.reduce<Uri[]>( |
|
|
(a, b) => a.concat(b.resourceStates.map(s => s.resourceUri)), |
|
|
(a, b) => a.concat(b.resourceStates.map(s => s.resourceUri)), |
|
|
[] |
|
|
[] |
|
|
); |
|
|
); |
|
|
return this.execute(args); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return this.execute(args); |
|
|
return this.execute(args); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async execute(args: StashSaveCommandArgs = {}) { |
|
|
async execute(args: StashSaveCommandArgs = {}) { |
|
|
let repoPath = await Container.git.getHighlanderRepoPath(); |
|
|
|
|
|
if (!repoPath) { |
|
|
|
|
|
const pick = await RepositoriesQuickPick.show( |
|
|
|
|
|
`Stash changes for which repository${GlyphChars.Ellipsis}`, |
|
|
|
|
|
args.goBackCommand |
|
|
|
|
|
); |
|
|
|
|
|
if (pick instanceof CommandQuickPickItem) return pick.execute(); |
|
|
|
|
|
if (pick === undefined) return args.goBackCommand === undefined ? undefined : args.goBackCommand.execute(); |
|
|
|
|
|
|
|
|
|
|
|
repoPath = pick.repoPath; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const uri = args.uris !== undefined && args.uris.length !== 0 ? args.uris[0] : undefined; |
|
|
|
|
|
const repoPath = await getRepoPathOrPrompt( |
|
|
|
|
|
uri, |
|
|
|
|
|
`Stash changes for which repository${GlyphChars.Ellipsis}`, |
|
|
|
|
|
args.goBackCommand |
|
|
|
|
|
); |
|
|
|
|
|
if (!repoPath) return undefined; |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
if (args.message == null) { |
|
|
if (args.message == null) { |
|
|