提交 dc8f4d6f 编写于 作者: M Mike Seese

Check git enableSmartCommit if no staged files

上级 5d323a3e
......@@ -530,6 +530,30 @@ export class CommandCenter {
getCommitMessage: () => Promise<string | undefined>,
opts?: CommitOptions
): Promise<boolean> {
const config = workspace.getConfiguration('git');
const enableSmartCommit = config.get<boolean>('enableSmartCommit') === true;
const noStagedChanges = this.model.indexGroup.resources.length === 0;
// no changes, and the user has not configured to commit all in this case
if (noStagedChanges && !enableSmartCommit) {
// prompt the user if we want to commit all or not
const message = localize('no staged changes', "There are no staged changes to commit. Would you like to stage all changes and commit them?");
const yes = localize('yes', "Yes");
const always = localize('always', "Always");
const pick = await window.showWarningMessage(message, { modal: true }, yes, always);
if (pick === always) {
// update preference to enable smart commit always
config.update('enableSmartCommit', true, false);
}
else if (pick !== yes) {
// do not commit on cancel
return false;
}
// for yes or always, continue onto previous smart commit behavior
}
if (!opts) {
opts = { all: this.model.indexGroup.resources.length === 0 };
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册