aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git/gerrit
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2020-02-25 20:20:25 +0200
committerOrgad Shaneh <orgads@gmail.com>2020-02-26 10:29:27 +0000
commit7c4f0a9b1ed29e9440211e37e45d0e3451ac2a62 (patch)
treeb37f939747b7450136552a55d9930823b8659a8b /src/plugins/git/gerrit
parent5765bd8507b1e76ef61176435ce357962fb9b291 (diff)
Git: Store singleton instance in GitClient
On many cases, GitPlugin is not required at all, and is only used as a proxy for GitClient. Change-Id: I246012658ab3e8c7a12f1a459b1b1748ff358e0b Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/git/gerrit')
-rw-r--r--src/plugins/git/gerrit/branchcombobox.cpp5
-rw-r--r--src/plugins/git/gerrit/gerritmodel.cpp3
-rw-r--r--src/plugins/git/gerrit/gerritplugin.cpp20
-rw-r--r--src/plugins/git/gerrit/gerritpushdialog.cpp19
-rw-r--r--src/plugins/git/gerrit/gerritremotechooser.cpp3
-rw-r--r--src/plugins/git/gerrit/gerritserver.cpp4
6 files changed, 25 insertions, 29 deletions
diff --git a/src/plugins/git/gerrit/branchcombobox.cpp b/src/plugins/git/gerrit/branchcombobox.cpp
index 6cc866ce3f1..bc7aa282df2 100644
--- a/src/plugins/git/gerrit/branchcombobox.cpp
+++ b/src/plugins/git/gerrit/branchcombobox.cpp
@@ -24,7 +24,6 @@
****************************************************************************/
#include "branchcombobox.h"
-#include "../gitplugin.h"
#include "../gitclient.h"
using namespace Git::Internal;
@@ -36,7 +35,7 @@ BranchComboBox::BranchComboBox(QWidget *parent) : QComboBox(parent)
void BranchComboBox::init(const QString &repository)
{
m_repository = repository;
- QString currentBranch = GitPlugin::client()->synchronousCurrentLocalBranch(repository);
+ QString currentBranch = GitClient::instance()->synchronousCurrentLocalBranch(repository);
if (currentBranch.isEmpty()) {
m_detached = true;
currentBranch = "HEAD";
@@ -44,7 +43,7 @@ void BranchComboBox::init(const QString &repository)
}
QString output;
const QString branchPrefix("refs/heads/");
- if (!GitPlugin::client()->synchronousForEachRefCmd(
+ if (!GitClient::instance()->synchronousForEachRefCmd(
m_repository, {"--format=%(refname)", branchPrefix}, &output)) {
return;
}
diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp
index a9be6358ccb..c5e346aaa6e 100644
--- a/src/plugins/git/gerrit/gerritmodel.cpp
+++ b/src/plugins/git/gerrit/gerritmodel.cpp
@@ -24,7 +24,6 @@
****************************************************************************/
#include "gerritmodel.h"
-#include "../gitplugin.h"
#include "../gitclient.h"
#include <coreplugin/progressmanager/progressmanager.h>
@@ -295,7 +294,7 @@ QueryContext::QueryContext(const QString &query,
connect(&m_process, &QProcess::errorOccurred, this, &QueryContext::processError);
connect(&m_watcher, &QFutureWatcherBase::canceled, this, &QueryContext::terminate);
m_watcher.setFuture(m_progress.future());
- m_process.setProcessEnvironment(Git::Internal::GitPlugin::client()->processEnvironment());
+ m_process.setProcessEnvironment(Git::Internal::GitClient::instance()->processEnvironment());
m_progress.setProgressRange(0, 1);
m_timer.setInterval(timeOutMS);
diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp
index 656f1e34f70..85d414b9b9a 100644
--- a/src/plugins/git/gerrit/gerritplugin.cpp
+++ b/src/plugins/git/gerrit/gerritplugin.cpp
@@ -148,7 +148,7 @@ FetchContext::FetchContext(const QSharedPointer<GerritChange> &change,
connect(&m_watcher, &QFutureWatcher<void>::canceled, this, &FetchContext::terminate);
m_watcher.setFuture(m_progress.future());
m_process.setWorkingDirectory(repository);
- m_process.setProcessEnvironment(GitPlugin::client()->processEnvironment());
+ m_process.setProcessEnvironment(GitClient::instance()->processEnvironment());
m_process.closeWriteChannel();
}
@@ -240,7 +240,7 @@ void FetchContext::show()
{
const QString title = QString::number(m_change->number) + '/'
+ QString::number(m_change->currentPatchSet.patchSetNumber);
- GitPlugin::client()->show(m_repository, "FETCH_HEAD", title);
+ GitClient::instance()->show(m_repository, "FETCH_HEAD", title);
}
void FetchContext::cherryPick()
@@ -248,12 +248,12 @@ void FetchContext::cherryPick()
// Point user to errors.
VcsBase::VcsOutputWindow::instance()->popup(IOutputPane::ModeSwitch
| IOutputPane::WithFocus);
- GitPlugin::client()->synchronousCherryPick(m_repository, "FETCH_HEAD");
+ GitClient::instance()->synchronousCherryPick(m_repository, "FETCH_HEAD");
}
void FetchContext::checkout()
{
- GitPlugin::client()->checkout(m_repository, "FETCH_HEAD");
+ GitClient::instance()->checkout(m_repository, "FETCH_HEAD");
}
void FetchContext::terminate()
@@ -328,7 +328,7 @@ void GerritPlugin::push(const QString &topLevel)
dialog.storeTopic();
m_reviewers = dialog.reviewers();
- GitPlugin::client()->push(topLevel, {dialog.selectedRemoteName(), dialog.pushTarget()});
+ GitClient::instance()->push(topLevel, {dialog.selectedRemoteName(), dialog.pushTarget()});
}
static QString currentRepository()
@@ -375,19 +375,19 @@ void GerritPlugin::push()
Utils::FilePath GerritPlugin::gitBinDirectory()
{
- return GitPlugin::client()->gitBinDirectory();
+ return GitClient::instance()->gitBinDirectory();
}
// Find the branch of a repository.
QString GerritPlugin::branch(const QString &repository)
{
- return GitPlugin::client()->synchronousCurrentLocalBranch(repository);
+ return GitClient::instance()->synchronousCurrentLocalBranch(repository);
}
void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
{
// Locate git.
- const Utils::FilePath git = GitPlugin::client()->vcsBinary();
+ const Utils::FilePath git = GitClient::instance()->vcsBinary();
if (git.isEmpty()) {
VcsBase::VcsOutputWindow::appendError(tr("Git is not available."));
return;
@@ -400,7 +400,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
if (!repository.isEmpty()) {
// Check if remote from a working dir is the same as remote from patch
- QMap<QString, QString> remotesList = GitPlugin::client()->synchronousRemotesList(repository);
+ QMap<QString, QString> remotesList = GitClient::instance()->synchronousRemotesList(repository);
if (!remotesList.isEmpty()) {
const QStringList remotes = remotesList.values();
for (QString remote : remotes) {
@@ -413,7 +413,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
}
if (!verifiedRepository) {
- const SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository);
+ const SubmoduleDataMap submodules = GitClient::instance()->submoduleList(repository);
for (const SubmoduleData &submoduleData : submodules) {
QString remote = submoduleData.url;
if (remote.endsWith(".git"))
diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp
index 08c280fc90f..ddd45134f79 100644
--- a/src/plugins/git/gerrit/gerritpushdialog.cpp
+++ b/src/plugins/git/gerrit/gerritpushdialog.cpp
@@ -27,7 +27,6 @@
#include "ui_gerritpushdialog.h"
#include "branchcombobox.h"
-#include "../gitplugin.h"
#include "../gitclient.h"
#include "../gitconstants.h"
@@ -70,7 +69,7 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
QString output;
QString error;
- if (!GitPlugin::client()->synchronousBranchCmd(
+ if (!GitClient::instance()->synchronousBranchCmd(
m_workingDir, {"-r", "--contains", earliestCommit + '^'}, &output, &error)) {
return QString();
}
@@ -79,7 +78,7 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
QString remoteTrackingBranch;
if (localBranch != "HEAD")
- remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch);
+ remoteTrackingBranch = GitClient::instance()->synchronousTrackingBranch(m_workingDir, localBranch);
QString remoteBranch;
for (const QString &reference : refs) {
@@ -103,7 +102,7 @@ void GerritPushDialog::initRemoteBranches()
const QString head = "/HEAD";
QString remotesPrefix("refs/remotes/");
- if (!GitPlugin::client()->synchronousForEachRefCmd(
+ if (!GitClient::instance()->synchronousForEachRefCmd(
m_workingDir, {"--format=%(refname)\t%(committerdate:raw)", remotesPrefix}, &output)) {
return;
}
@@ -186,8 +185,8 @@ QString GerritPushDialog::calculateChangeRange(const QString &branch)
QString number;
QString error;
- GitPlugin::client()->synchronousRevListCmd(m_workingDir, { remote + ".." + branch, "--count" },
- &number, &error);
+ GitClient::instance()->synchronousRevListCmd(
+ m_workingDir, { remote + ".." + branch, "--count" }, &number, &error);
number.chop(1);
return number;
@@ -303,8 +302,8 @@ QString GerritPushDialog::pushTarget() const
void GerritPushDialog::storeTopic()
{
const QString branch = m_ui->localBranchComboBox->currentText();
- GitPlugin::client()->setConfigValue(m_workingDir, QString("branch.%1.topic").arg(branch),
- selectedTopic());
+ GitClient::instance()->setConfigValue(
+ m_workingDir, QString("branch.%1.topic").arg(branch), selectedTopic());
}
void GerritPushDialog::setRemoteBranches(bool includeOld)
@@ -316,7 +315,7 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
const QString remoteName = selectedRemoteName();
if (!m_remoteBranches.contains(remoteName)) {
const QStringList remoteBranches =
- GitPlugin::client()->synchronousRepositoryBranches(remoteName, m_workingDir);
+ GitClient::instance()->synchronousRepositoryBranches(remoteName, m_workingDir);
for (const QString &branch : remoteBranches)
m_remoteBranches.insertMulti(remoteName, qMakePair(branch, QDate()));
if (remoteBranches.isEmpty()) {
@@ -354,7 +353,7 @@ void GerritPushDialog::updateCommits(int index)
{
const QString branch = m_ui->localBranchComboBox->itemText(index);
m_hasLocalCommits = m_ui->commitView->init(m_workingDir, branch, LogChangeWidget::Silent);
- QString topic = GitPlugin::client()->readConfigValue(
+ QString topic = GitClient::instance()->readConfigValue(
m_workingDir, QString("branch.%1.topic").arg(branch));
if (!topic.isEmpty())
m_ui->topicLineEdit->setText(topic);
diff --git a/src/plugins/git/gerrit/gerritremotechooser.cpp b/src/plugins/git/gerrit/gerritremotechooser.cpp
index 8e5e7cd8828..6b94bcd238f 100644
--- a/src/plugins/git/gerrit/gerritremotechooser.cpp
+++ b/src/plugins/git/gerrit/gerritremotechooser.cpp
@@ -27,7 +27,6 @@
#include "gerritparameters.h"
#include "gerritserver.h"
#include "../gitclient.h"
-#include "../gitplugin.h"
#include <utils/qtcassert.h>
#include <utils/utilsicons.h>
@@ -104,7 +103,7 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload)
m_remotes.clear();
QString errorMessage; // Mute errors. We'll just fallback to the defaults
const QMap<QString, QString> remotesList =
- Git::Internal::GitPlugin::client()->synchronousRemotesList(m_repository, &errorMessage);
+ Git::Internal::GitClient::instance()->synchronousRemotesList(m_repository, &errorMessage);
for (auto mapIt = remotesList.cbegin(), end = remotesList.cend(); mapIt != end; ++mapIt) {
GerritServer server;
if (!server.fillFromRemote(mapIt.value(), *m_parameters, forceReload))
diff --git a/src/plugins/git/gerrit/gerritserver.cpp b/src/plugins/git/gerrit/gerritserver.cpp
index f2fae53d517..a0a6a650469 100644
--- a/src/plugins/git/gerrit/gerritserver.cpp
+++ b/src/plugins/git/gerrit/gerritserver.cpp
@@ -241,7 +241,7 @@ QStringList GerritServer::curlArguments() const
int GerritServer::testConnection()
{
- static GitClient *const client = GitPlugin::client();
+ static GitClient *const client = GitClient::instance();
const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC);
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
QString(), {curlBinary, arguments},
@@ -333,7 +333,7 @@ bool GerritServer::resolveRoot()
void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
{
- static GitClient *const client = GitPlugin::client();
+ static GitClient *const client = GitClient::instance();
QSettings *settings = Core::ICore::settings();
const QString fullVersionKey = "Gerrit/" + host + '/' + versionKey;
version = settings->value(fullVersionKey).toString();