diff --git a/extensions/git/package.json b/extensions/git/package.json index 284dadb435219..72428c5063aa1 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -2012,6 +2012,12 @@ "default": true, "description": "%config.terminalAuthentication%" }, + "git.defaultStashMessage": { + "type": "boolean", + "scope": "resource", + "default": false, + "description": "%config.defaultStashMessage%" + }, "git.githubAuthentication": { "deprecationMessage": "This setting is now deprecated, please use `github.gitAuthentication` instead." }, diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 19d3c5baf1bfd..c013d399f9fdc 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -176,6 +176,7 @@ "config.timeline.date": "Controls which date to use for items in the Timeline view", "config.timeline.date.committed": "Use the committed date", "config.timeline.date.authored": "Use the authored date", + "config.defaultStashMessage": "Controls whether to use message from commit input box (if populated) as default stash messages", "submenu.commit": "Commit", "submenu.commit.amend": "Amend", "submenu.commit.signoff": "Sign Off", diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 708ee1d6a11ac..42992ad9b06ae 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -2506,7 +2506,16 @@ export class CommandCenter { } } - const message = await this.getStashMessage(); + let defaultStashMessage = ''; + if (config.get('defaultStashMessage')) { + const commitTemplate = repository.sourceControl.commitTemplate; + if (commitTemplate === undefined) { + defaultStashMessage = repository.inputBox.value; + } else { + defaultStashMessage = repository.inputBox.value.replace(commitTemplate, ''); + } + } + const message = await this.getStashMessage(defaultStashMessage); if (typeof message === 'undefined') { return; @@ -2515,8 +2524,9 @@ export class CommandCenter { await repository.createStash(message, includeUntracked); } - private async getStashMessage(): Promise { + private async getStashMessage(defaultStashMessage: string): Promise { return await window.showInputBox({ + value: defaultStashMessage, prompt: localize('provide stash message', "Optionally provide a stash message"), placeHolder: localize('stash message', "Stash message") });