Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: detect default stash message microsoft#106907 #107074

Merged
merged 3 commits into from
Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions extensions/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
},
Expand Down
1 change: 1 addition & 0 deletions extensions/git/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 12 additions & 2 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,16 @@ export class CommandCenter {
}
}

const message = await this.getStashMessage();
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, '');
}
}
const message = await this.getStashMessage(defaultStashMessage);

if (typeof message === 'undefined') {
return;
Expand All @@ -2515,8 +2524,9 @@ export class CommandCenter {
await repository.createStash(message, includeUntracked);
}

private async getStashMessage(): Promise<string | undefined> {
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")
});
Expand Down