Commit e427eab0 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Close submit editor if all changes were committed externally



Change-Id: Iae4e9d52aed333def0e5f0c56bca9c68a38430a4
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent e4e43352
...@@ -916,11 +916,15 @@ bool GitPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEdi ...@@ -916,11 +916,15 @@ bool GitPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEdi
// Prompt user. Force a prompt unless submit was actually invoked (that // Prompt user. Force a prompt unless submit was actually invoked (that
// is, the editor was closed or shutdown). // is, the editor was closed or shutdown).
bool *promptData = m_settings.boolPointer(GitSettings::promptOnSubmitKey); bool *promptData = m_settings.boolPointer(GitSettings::promptOnSubmitKey);
const VcsBase::VcsBaseSubmitEditor::PromptSubmitResult answer = VcsBase::VcsBaseSubmitEditor::PromptSubmitResult answer;
editor->promptSubmit(tr("Closing Git Editor"), if (editor->forceClose()) {
tr("Do you want to commit the change?"), answer = VcsBase::VcsBaseSubmitEditor::SubmitDiscarded;
tr("Git will not accept this commit. Do you want to continue to edit it?"), } else {
promptData, !m_submitActionTriggered, false); answer = editor->promptSubmit(tr("Closing Git Editor"),
tr("Do you want to commit the change?"),
tr("Git will not accept this commit. Do you want to continue to edit it?"),
promptData, !m_submitActionTriggered, false);
}
m_submitActionTriggered = false; m_submitActionTriggered = false;
switch (answer) { switch (answer) {
case VcsBase::VcsBaseSubmitEditor::SubmitCanceled: case VcsBase::VcsBaseSubmitEditor::SubmitCanceled:
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "gitsubmiteditor.h" #include "gitsubmiteditor.h"
#include "gitsubmiteditorwidget.h" #include "gitsubmiteditorwidget.h"
#include <coreplugin/editormanager/editormanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <vcsbase/submitfilemodel.h> #include <vcsbase/submitfilemodel.h>
#include <vcsbase/vcsbaseoutputwindow.h> #include <vcsbase/vcsbaseoutputwindow.h>
...@@ -85,7 +86,8 @@ private: ...@@ -85,7 +86,8 @@ private:
GitSubmitEditor::GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters, QWidget *parent) : GitSubmitEditor::GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters, QWidget *parent) :
VcsBaseSubmitEditor(parameters, new GitSubmitEditorWidget(parent)), VcsBaseSubmitEditor(parameters, new GitSubmitEditorWidget(parent)),
m_model(0), m_model(0),
m_amend(false) m_amend(false),
m_forceClose(false)
{ {
connect(this, SIGNAL(diffSelectedFiles(QList<int>)), this, SLOT(slotDiffSelected(QList<int>))); connect(this, SIGNAL(diffSelectedFiles(QList<int>)), this, SLOT(slotDiffSelected(QList<int>)));
} }
...@@ -162,10 +164,13 @@ void GitSubmitEditor::updateFileModel() ...@@ -162,10 +164,13 @@ void GitSubmitEditor::updateFileModel()
GitClient *client = GitPlugin::instance()->gitClient(); GitClient *client = GitPlugin::instance()->gitClient();
QString errorMessage, commitTemplate; QString errorMessage, commitTemplate;
CommitData data; CommitData data;
if (client->getCommitData(m_workingDirectory, m_amend, &commitTemplate, &data, &errorMessage)) if (client->getCommitData(m_workingDirectory, m_amend, &commitTemplate, &data, &errorMessage)) {
setCommitData(data); setCommitData(data);
else } else {
VcsBase::VcsBaseOutputWindow::instance()->append(errorMessage); VcsBase::VcsBaseOutputWindow::instance()->append(errorMessage);
m_forceClose = true;
Core::EditorManager::instance()->closeEditors(QList<IEditor*>() << this);
}
} }
GitSubmitEditorPanelData GitSubmitEditor::panelData() const GitSubmitEditorPanelData GitSubmitEditor::panelData() const
......
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
void setCommitData(const CommitData &); void setCommitData(const CommitData &);
void setAmend(bool amend); void setAmend(bool amend);
GitSubmitEditorPanelData panelData() const; GitSubmitEditorPanelData panelData() const;
bool forceClose() const { return m_forceClose; }
signals: signals:
void diff(const QStringList &unstagedFiles, const QStringList &stagedFiles); void diff(const QStringList &unstagedFiles, const QStringList &stagedFiles);
...@@ -72,6 +73,7 @@ private: ...@@ -72,6 +73,7 @@ private:
VcsBase::SubmitFileModel *m_model; VcsBase::SubmitFileModel *m_model;
QString m_commitEncoding; QString m_commitEncoding;
bool m_amend; bool m_amend;
bool m_forceClose;
QString m_workingDirectory; QString m_workingDirectory;
}; };
......
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