From 19c0c60064b6224fddc613f3d347b8cd404b7c0e Mon Sep 17 00:00:00 2001 From: dfireBird Date: Sun, 20 Sep 2020 00:08:35 +0530 Subject: [PATCH 1/3] feat: detect default stash message use commit message as default stash message if commit message box is populated --- extensions/git/src/commands.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 708ee1d6a11ac..7a2a7362b4501 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -2506,7 +2506,7 @@ export class CommandCenter { } } - const message = await this.getStashMessage(); + const message = await this.getStashMessage(repository.inputBox.value)); if (typeof message === 'undefined') { return; @@ -2515,8 +2515,9 @@ export class CommandCenter { await repository.createStash(message, includeUntracked); } - private async getStashMessage(): Promise { + private async getStashMessage(message: string): Promise { return await window.showInputBox({ + value: message, prompt: localize('provide stash message', "Optionally provide a stash message"), placeHolder: localize('stash message', "Stash message") }); From 109d9984c1193b8af9a8e24bd1e741aefbc5fd92 Mon Sep 17 00:00:00 2001 From: dfireBird Date: Mon, 21 Sep 2020 22:20:27 +0530 Subject: [PATCH 2/3] fix: commit template appears as default stash message --- extensions/git/src/commands.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 7a2a7362b4501..c0d251a1d98c9 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -2506,7 +2506,14 @@ export class CommandCenter { } } - const message = await this.getStashMessage(repository.inputBox.value)); + let defaultStashMessage: string; + 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,9 +2522,9 @@ export class CommandCenter { await repository.createStash(message, includeUntracked); } - private async getStashMessage(message: string): Promise { + private async getStashMessage(defaultStashMessage: string): Promise { return await window.showInputBox({ - value: message, + value: defaultStashMessage, prompt: localize('provide stash message', "Optionally provide a stash message"), placeHolder: localize('stash message', "Stash message") }); From 024df3355377d566bcad4fa54b7fadbdeb6e39d3 Mon Sep 17 00:00:00 2001 From: dfireBird Date: Mon, 21 Sep 2020 23:33:44 +0530 Subject: [PATCH 3/3] feat: add setting for default stash message --- extensions/git/package.json | 6 ++++++ extensions/git/package.nls.json | 1 + extensions/git/src/commands.ts | 14 ++++++++------ 3 files changed, 15 insertions(+), 6 deletions(-) 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 c0d251a1d98c9..42992ad9b06ae 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -2506,12 +2506,14 @@ export class CommandCenter { } } - let defaultStashMessage: string; - const commitTemplate = repository.sourceControl.commitTemplate; - if (commitTemplate === undefined) { - defaultStashMessage = repository.inputBox.value; - } else { - defaultStashMessage = repository.inputBox.value.replace(commitTemplate, ''); + 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);