This commit is contained in:
João Moreno 2020-11-10 11:41:40 +01:00
parent 1d18ebe47e
commit 13f9f73353
No known key found for this signature in database
GPG key ID: 896B853774D1A575
3 changed files with 13 additions and 20 deletions

View file

@ -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."

View file

@ -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",

View file

@ -2606,16 +2606,17 @@ export class CommandCenter {
}
}
let defaultStashMessage = '';
if (config.get<boolean>('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<boolean>('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<string | undefined> {
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<void> {
return this._stash(repository);