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>
This commit is contained in:
Orgad Shaneh
2020-02-25 20:20:25 +02:00
committed by Orgad Shaneh
parent 5765bd8507
commit 7c4f0a9b1e
19 changed files with 123 additions and 118 deletions

View File

@@ -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);