forked from qt-creator/qt-creator
Git: Do not accept invalid commits
Do not offer to commit in the dialog opened when closing the commit editor when the commit is not containing all the required information.
This commit is contained in:
@@ -126,6 +126,8 @@ public:
|
||||
void addSubmitFieldWidget(SubmitFieldWidget *f);
|
||||
QList<SubmitFieldWidget *> submitFieldWidgets() const;
|
||||
|
||||
virtual bool canSubmit() const;
|
||||
|
||||
signals:
|
||||
void diffSelected(const QStringList &);
|
||||
void fileSelectionChanged(bool someFileSelected);
|
||||
@@ -139,7 +141,6 @@ public slots:
|
||||
protected:
|
||||
virtual void changeEvent(QEvent *e);
|
||||
void insertTopWidget(QWidget *w);
|
||||
virtual bool canSubmit() const;
|
||||
|
||||
protected slots:
|
||||
void updateSubmitAction();
|
||||
|
||||
@@ -756,8 +756,8 @@ bool GitPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEdi
|
||||
const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult answer =
|
||||
editor->promptSubmit(tr("Closing Git Editor"),
|
||||
tr("Do you want to commit the change?"),
|
||||
tr("The commit message check failed. Do you want to commit the change?"),
|
||||
&settings.promptToSubmit, !m_submitActionTriggered);
|
||||
tr("Git will not accept this commit. Do you want to continue to edit it?"),
|
||||
&settings.promptToSubmit, !m_submitActionTriggered, false);
|
||||
m_submitActionTriggered = false;
|
||||
switch (answer) {
|
||||
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
|
||||
|
||||
@@ -464,8 +464,12 @@ VCSBaseSubmitEditor::PromptSubmitResult
|
||||
const QString &question,
|
||||
const QString &checkFailureQuestion,
|
||||
bool *promptSetting,
|
||||
bool forcePrompt) const
|
||||
bool forcePrompt,
|
||||
bool canCommitOnFailure) const
|
||||
{
|
||||
Utils::SubmitEditorWidget *submitWidget =
|
||||
static_cast<Utils::SubmitEditorWidget *>(const_cast<VCSBaseSubmitEditor *>(this)->widget());
|
||||
|
||||
raiseSubmitEditor();
|
||||
|
||||
QString errorMessage;
|
||||
@@ -476,7 +480,8 @@ VCSBaseSubmitEditor::PromptSubmitResult
|
||||
QWidget *parent = Core::ICore::instance()->mainWindow();
|
||||
// Pop up a message depending on whether the check succeeded and the
|
||||
// user wants to be prompted
|
||||
if (checkSubmitMessage(&errorMessage)) {
|
||||
bool canCommit = checkSubmitMessage(&errorMessage) && submitWidget->canSubmit();
|
||||
if (canCommit) {
|
||||
// Check ok, do prompt?
|
||||
if (prompt) {
|
||||
// Provide check box to turn off prompt ONLY if it was not forced
|
||||
@@ -503,6 +508,16 @@ VCSBaseSubmitEditor::PromptSubmitResult
|
||||
msgBox.setMinimumWidth(checkDialogMinimumWidth);
|
||||
answer = static_cast<QMessageBox::StandardButton>(msgBox.exec());
|
||||
}
|
||||
if (!canCommit && !canCommitOnFailure) {
|
||||
switch (answer) {
|
||||
case QMessageBox::No:
|
||||
return SubmitDiscarded;
|
||||
case QMessageBox::Yes:
|
||||
return SubmitCanceled;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (answer) {
|
||||
case QMessageBox::No:
|
||||
return SubmitDiscarded;
|
||||
@@ -511,6 +526,8 @@ VCSBaseSubmitEditor::PromptSubmitResult
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return SubmitCanceled;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,8 @@ public:
|
||||
PromptSubmitResult promptSubmit(const QString &title, const QString &question,
|
||||
const QString &checkFailureQuestion,
|
||||
bool *promptSetting,
|
||||
bool forcePrompt = false) const;
|
||||
bool forcePrompt = false,
|
||||
bool canCommitOnFailure = true) const;
|
||||
|
||||
int fileNameColumn() const;
|
||||
void setFileNameColumn(int c);
|
||||
|
||||
Reference in New Issue
Block a user