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