summaryrefslogtreecommitdiff
path: root/src/plugins/git
diff options
context:
space:
mode:
authorPetar Perisin <petar.perisin@gmail.com>2013-09-30 01:46:10 +0200
committerPetar Perisin <petar.perisin@gmail.com>2013-11-08 12:42:08 +0100
commit6c61559399ae43a9c6ae7cd9fd51185c135968a2 (patch)
tree157c42a553e7d3de86ee0c337454bda4e97c73dd /src/plugins/git
parentabfa553986923613fb8147f6663bc9773edded9c (diff)
downloadqt-creator-6c61559399ae43a9c6ae7cd9fd51185c135968a2.tar.gz
Git: Allow push after fixup
Direct push after fixup is really useful, especially on gerrit, because it allows easy fixing and direct pushing commits under HEAD. Change-Id: I83980e451c9ae86ac1ac0a55170d6d4141f27d49 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/git')
-rw-r--r--src/plugins/git/gitclient.cpp19
-rw-r--r--src/plugins/git/gitclient.h8
-rw-r--r--src/plugins/git/gitplugin.cpp9
-rw-r--r--src/plugins/git/gitplugin.h1
-rw-r--r--src/plugins/git/gitsubmiteditorwidget.cpp2
5 files changed, 31 insertions, 8 deletions
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 416c29e5d3..01f38b8b7c 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -38,6 +38,7 @@
#include "mergetool.h"
#include "branchadddialog.h"
+#include <gerrit/gerritplugin.h>
#include <vcsbase/submitfilemodel.h>
#include <coreplugin/editormanager/editormanager.h>
@@ -2526,12 +2527,13 @@ QProcessEnvironment GitClient::processEnvironment() const
return environment;
}
-bool GitClient::beginStashScope(const QString &workingDirectory, const QString &command, StashFlag flag)
+bool GitClient::beginStashScope(const QString &workingDirectory, const QString &command,
+ StashFlag flag, PushAction pushAction)
{
const QString repoDirectory = findRepositoryForDirectory(workingDirectory);
QTC_ASSERT(!repoDirectory.isEmpty(), return false);
StashInfo &stashInfo = m_stashInfo[repoDirectory];
- return stashInfo.init(repoDirectory, command, flag);
+ return stashInfo.init(repoDirectory, command, flag, pushAction);
}
GitClient::StashInfo &GitClient::stashInfo(const QString &workingDirectory)
@@ -3807,15 +3809,17 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const
}
GitClient::StashInfo::StashInfo() :
- m_client(GitPlugin::instance()->gitClient())
+ m_client(GitPlugin::instance()->gitClient()),
+ m_pushAction(NoPush)
{
}
bool GitClient::StashInfo::init(const QString &workingDirectory, const QString &command,
- StashFlag flag)
+ StashFlag flag, PushAction pushAction)
{
m_workingDir = workingDirectory;
m_flags = flag;
+ m_pushAction = pushAction;
QString errorMessage;
QString statusOutput;
switch (m_client->gitStatus(m_workingDir, StatusMode(NoUntracked | NoSubmodules),
@@ -3914,6 +3918,13 @@ void GitClient::StashInfo::end()
if (m_client->stashNameFromMessage(m_workingDir, m_message, &stashName))
m_client->stashPop(m_workingDir, stashName);
}
+
+ if (m_pushAction == NormalPush)
+ m_client->push(m_workingDir);
+ else if (m_pushAction == PushToGerrit)
+ GitPlugin::instance()->gerritPlugin()->push(m_workingDir);
+
+ m_pushAction = NoPush;
m_stashResult = NotStashed;
}
} // namespace Internal
diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h
index f9d7f8a5fa..49c440168c 100644
--- a/src/plugins/git/gitclient.h
+++ b/src/plugins/git/gitclient.h
@@ -31,6 +31,7 @@
#define GITCLIENT_H
#include "gitsettings.h"
+#include "commitdata.h"
#include <coreplugin/editormanager/ieditor.h>
@@ -110,7 +111,8 @@ public:
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
Stashed, NotStashed /* User did not want it */ };
- bool init(const QString &workingDirectory, const QString &command, StashFlag flag = Default);
+ bool init(const QString &workingDirectory, const QString &command,
+ StashFlag flag = Default, PushAction pushAction = NoPush);
bool stashingFailed() const;
void end();
StashResult result() const { return m_stashResult; }
@@ -125,6 +127,7 @@ public:
QString m_workingDir;
GitClient *m_client;
StashFlag m_flags;
+ PushAction m_pushAction;
};
static const char *stashNamePrefix;
@@ -322,7 +325,8 @@ public:
QProcessEnvironment processEnvironment() const;
- bool beginStashScope(const QString &workingDirectory, const QString &command, StashFlag flag = Default);
+ bool beginStashScope(const QString &workingDirectory, const QString &command,
+ StashFlag flag = Default, PushAction pushAction = NoPush);
StashInfo &stashInfo(const QString &workingDirectory);
void endStashScope(const QString &workingDirectory);
bool isValidRevision(const QString &revision) const;
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index 06ed7d2ca9..f055c3f4b3 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -1132,8 +1132,10 @@ bool GitPlugin::submitEditorAboutToClose()
return false;
cleanCommitMessageFile();
if (commitType == FixupCommit) {
- if (!m_gitClient->beginStashScope(m_submitRepository, QLatin1String("Rebase-fixup"), NoPrompt))
+ if (!m_gitClient->beginStashScope(m_submitRepository, QLatin1String("Rebase-fixup"),
+ NoPrompt, editor->panelData().pushAction)) {
return false;
+ }
m_gitClient->interactiveRebase(m_submitRepository, amendSHA1, true);
} else {
m_gitClient->continueCommandIfNeeded(m_submitRepository);
@@ -1506,6 +1508,11 @@ GitClient *GitPlugin::gitClient() const
return m_gitClient;
}
+Gerrit::Internal::GerritPlugin *GitPlugin::gerritPlugin() const
+{
+ return m_gerritPlugin;
+}
+
#ifdef WITH_TESTS
#include <QTest>
diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h
index f451834f30..f72de8c4a3 100644
--- a/src/plugins/git/gitplugin.h
+++ b/src/plugins/git/gitplugin.h
@@ -99,6 +99,7 @@ public:
void setSettings(const GitSettings &s);
GitClient *gitClient() const;
+ Gerrit::Internal::GerritPlugin *gerritPlugin() const;
public slots:
void startCommit();
diff --git a/src/plugins/git/gitsubmiteditorwidget.cpp b/src/plugins/git/gitsubmiteditorwidget.cpp
index 50cffe06b7..03c4fcffee 100644
--- a/src/plugins/git/gitsubmiteditorwidget.cpp
+++ b/src/plugins/git/gitsubmiteditorwidget.cpp
@@ -109,7 +109,7 @@ void GitSubmitEditorWidget::initialize(CommitType commitType,
setPanelData(data);
setPanelInfo(info);
- if (enablePush && commitType != FixupCommit) {
+ if (enablePush) {
QMenu *menu = new QMenu(this);
menu->addAction(tr("&Commit only"), this, SLOT(commitOnlySlot()));
menu->addAction(tr("Commit and &Push"), this, SLOT(commitAndPushSlot()));