From fe6864f64974bc96d17f28e0d0a8f7f382454f77 Mon Sep 17 00:00:00 2001 From: "m.zaretski" Date: Sun, 25 Nov 2018 17:32:09 +0300 Subject: [PATCH] 'suggestSmartCommit' configuration setting was introduced --- extensions/git/package.json | 6 ++++++ extensions/git/package.nls.json | 1 + extensions/git/src/commands.ts | 11 ++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/extensions/git/package.json b/extensions/git/package.json index ef4385ef3db42..f0d86ef1d8743 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -1097,6 +1097,12 @@ "description": "%config.enableSmartCommit%", "default": false }, + "git.suggestSmartCommit": { + "type": "boolean", + "scope": "resource", + "description": "%config.suggestSmartCommit%", + "default": true + }, "git.enableCommitSigning": { "type": "boolean", "scope": "resource", diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 356d1473bbca8..5c76ad62c33cc 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -85,6 +85,7 @@ "config.ignoreLimitWarning": "Ignores the warning when there are too many changes in a repository.", "config.defaultCloneDirectory": "The default location to clone a git repository.", "config.enableSmartCommit": "Commit all changes when there are no staged changes.", + "config.suggestSmartCommit": "Suggests to enable smart commit (commit all changes when there are no staged changes).", "config.enableCommitSigning": "Enables commit signing with GPG.", "config.discardAllScope": "Controls what changes are discarded by the `Discard all changes` command. `all` discards all changes. `tracked` discards only tracked files. `prompt` shows a prompt dialog every time the action is run.", "config.decorations.enabled": "Controls whether Git contributes colors and badges to the explorer and the open editors view.", diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index e41a8161c5683..11ff3cdd0ce69 100755 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -1192,14 +1192,23 @@ export class CommandCenter { // no changes, and the user has not configured to commit all in this case if (!noUnstagedChanges && noStagedChanges && !enableSmartCommit) { + const suggestSmartCommit = config.get('suggestSmartCommit') === true; + if (!suggestSmartCommit) { + return false; + } + // prompt the user if we want to commit all or not const message = localize('no staged changes', "There are no staged changes to commit.\n\nWould you like to automatically stage all your changes and commit them directly?"); const yes = localize('yes', "Yes"); const always = localize('always', "Always"); - const pick = await window.showWarningMessage(message, { modal: true }, yes, always); + const never = localize('never', "Never"); + const pick = await window.showWarningMessage(message, { modal: true }, yes, always, never); if (pick === always) { config.update('enableSmartCommit', true, true); + } else if (pick === never) { + config.update('suggestSmartCommit', false, true); + return false; } else if (pick !== yes) { return false; // do not commit on cancel }