Revert "Git - do not show smart commit dialog when using Commit (Amend) (#214595)" (#218377)

This reverts commit 5422f5f940.
This commit is contained in:
Ladislau Szomoru 2024-06-26 15:04:40 +02:00 committed by GitHub
parent 85f13f93f1
commit 64c1b1cc60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2103,38 +2103,36 @@ export class CommandCenter {
}
}
if (!opts.amend) {
// no changes, and the user has not configured to commit all in this case
if (!noUnstagedChanges && noStagedChanges && !enableSmartCommit && !opts.all) {
const suggestSmartCommit = config.get<boolean>('suggestSmartCommit') === true;
// no changes, and the user has not configured to commit all in this case
if (!noUnstagedChanges && noStagedChanges && !enableSmartCommit && !opts.all) {
const suggestSmartCommit = config.get<boolean>('suggestSmartCommit') === true;
if (!suggestSmartCommit) {
return;
}
// prompt the user if we want to commit all or not
const message = l10n.t('There are no staged changes to commit.\n\nWould you like to stage all your changes and commit them directly?');
const yes = l10n.t('Yes');
const always = l10n.t('Always');
const never = l10n.t('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;
} else if (pick !== yes) {
return; // do not commit on cancel
}
if (!suggestSmartCommit) {
return;
}
if (opts.all === undefined) {
opts = { ...opts, all: noStagedChanges };
} else if (!opts.all && noStagedChanges) {
opts = { ...opts, all: true };
// prompt the user if we want to commit all or not
const message = l10n.t('There are no staged changes to commit.\n\nWould you like to stage all your changes and commit them directly?');
const yes = l10n.t('Yes');
const always = l10n.t('Always');
const never = l10n.t('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;
} else if (pick !== yes) {
return; // do not commit on cancel
}
}
if (opts.all === undefined) {
opts = { ...opts, all: noStagedChanges };
} else if (!opts.all && noStagedChanges) {
opts = { ...opts, all: true };
}
}
// enable signing of commits if configured