diff --git a/extensions/git/package.json b/extensions/git/package.json index 0475c177a04..4ca0723655c 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -2068,11 +2068,11 @@ "default": true, "description": "%config.terminalAuthentication%" }, - "git.defaultStashMessage": { + "git.useCommitInputAsStashMessage": { "type": "boolean", "scope": "resource", "default": false, - "description": "%config.defaultStashMessage%" + "description": "%config.useCommitInputAsStashMessage%" }, "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 6345be0c8d2..2ae28a0c17e 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -179,7 +179,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", + "config.useCommitInputAsStashMessage": "Controls whether to use the message from the commit input box as the default stash message.", "submenu.explorer": "Git", "submenu.commit": "Commit", "submenu.commit.amend": "Amend", diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index ef39dce7804..10a51618071 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -2606,16 +2606,17 @@ export class CommandCenter { } } - 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, ''); - } + let message: string | undefined; + + if (config.get('useCommitInputAsStashMessage') && (!repository.sourceControl.commitTemplate || repository.inputBox.value !== repository.sourceControl.commitTemplate)) { + message = repository.inputBox.value; } - const message = await this.getStashMessage(defaultStashMessage); + + message = await window.showInputBox({ + value: message, + prompt: localize('provide stash message', "Optionally provide a stash message"), + placeHolder: localize('stash message', "Stash message") + }); if (typeof message === 'undefined') { return; @@ -2624,14 +2625,6 @@ export class CommandCenter { await repository.createStash(message, includeUntracked); } - 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") - }); - } - @command('git.stash', { repository: true }) stash(repository: Repository): Promise { return this._stash(repository);