Commit 2f07660e authored by Tobias Hunger's avatar Tobias Hunger

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.
parent f3b5c98b
......@@ -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,14 +508,26 @@ VCSBaseSubmitEditor::PromptSubmitResult
msgBox.setMinimumWidth(checkDialogMinimumWidth);
answer = static_cast<QMessageBox::StandardButton>(msgBox.exec());
}
switch (answer) {
case QMessageBox::No:
return SubmitDiscarded;
case QMessageBox::Yes:
return SubmitConfirmed;
default:
break;
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;
case QMessageBox::Yes:
return SubmitConfirmed;
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment