Git: Make Gerrit settings handling more similar to others

Use a singleton for the main settings, don't pass it around as
shared pointer.

Change-Id: I5c32679452ad631998a688afc9a6e2b154bf3a5d
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2024-07-16 10:04:08 +02:00
parent 2ddb7f66a8
commit 4d9bb822af
16 changed files with 101 additions and 151 deletions

View File

@@ -39,20 +39,17 @@
using namespace Utils;
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
static const int maxTitleWidth = 350;
GerritDialog::GerritDialog(const std::shared_ptr<GerritParameters> &p,
const std::shared_ptr<GerritServer> &s,
GerritDialog::GerritDialog(const std::shared_ptr<GerritServer> &s,
const FilePath &repository,
QWidget *parent)
: QDialog(parent)
, m_parameters(p)
, m_server(s)
, m_filterModel(new QSortFilterProxyModel(this))
, m_model(new GerritModel(p, this))
, m_model(new GerritModel(this))
, m_queryModel(new QStringListModel(this))
{
setWindowTitle(Git::Tr::tr("Gerrit"));
@@ -95,9 +92,8 @@ GerritDialog::GerritDialog(const std::shared_ptr<GerritParameters> &p,
auto queryLabel = new QLabel(Git::Tr::tr("&Query:"), changesGroup);
queryLabel->setBuddy(m_queryLineEdit);
m_remoteComboBox->setParameters(m_parameters);
m_remoteComboBox->setFallbackEnabled(true);
m_queryModel->setStringList(m_parameters->savedQueries);
m_queryModel->setStringList(gerritSettings().savedQueries);
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_filterModel->setSourceModel(m_model);
m_filterModel->setFilterRole(GerritModel::FilterRole);
@@ -210,11 +206,11 @@ void GerritDialog::updateCompletions(const QString &query)
{
if (query.isEmpty())
return;
QStringList &queries = m_parameters->savedQueries;
QStringList &queries = gerritSettings().savedQueries;
queries.removeAll(query);
queries.prepend(query);
m_queryModel->setStringList(queries);
m_parameters->saveQueries(Core::ICore::settings());
gerritSettings().saveQueries();
}
GerritDialog::~GerritDialog() = default;
@@ -300,7 +296,7 @@ void GerritDialog::updateRemotes(bool forceReload)
m_remoteComboBox->setRepository(m_repository);
if (m_repository.isEmpty() || !m_repository.isDir())
return;
*m_server = m_parameters->server;
*m_server = gerritSettings().server;
m_remoteComboBox->updateRemotes(forceReload);
}
@@ -360,5 +356,4 @@ void GerritDialog::setProgressIndicatorVisible(bool v)
m_progressIndicator->setVisible(v);
}
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal

View File

@@ -26,12 +26,10 @@ class ProgressIndicator;
class TreeView;
} // Utils
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
class GerritChange;
class GerritModel;
class GerritParameters;
class GerritRemoteChooser;
class GerritServer;
@@ -39,8 +37,7 @@ class GerritDialog : public QDialog
{
Q_OBJECT
public:
explicit GerritDialog(const std::shared_ptr<GerritParameters> &p,
const std::shared_ptr<GerritServer> &s,
explicit GerritDialog(const std::shared_ptr<GerritServer> &s,
const Utils::FilePath &repository,
QWidget *parent = nullptr);
~GerritDialog() override;
@@ -75,7 +72,6 @@ private:
QPushButton *addActionButton(const QString &text, const std::function<void ()> &buttonSlot);
void updateButtons();
const std::shared_ptr<GerritParameters> m_parameters;
const std::shared_ptr<GerritServer> m_server;
QSortFilterProxyModel *m_filterModel;
GerritModel *m_model;
@@ -99,5 +95,4 @@ private:
Utils::FancyLineEdit *m_queryLineEdit;
};
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "gerritmodel.h"
#include "gerritparameters.h"
#include "../gitclient.h"
#include "../gittr.h"
@@ -32,8 +33,7 @@ enum { debug = 0 };
using namespace Utils;
using namespace VcsBase;
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
QDebug operator<<(QDebug d, const GerritApproval &a)
{
@@ -64,11 +64,9 @@ QDebug operator<<(QDebug d, const GerritChange &c)
}
// Format default Url for a change
static inline QString defaultUrl(const std::shared_ptr<GerritParameters> &p,
const GerritServer &server,
int gerritNumber)
static QString defaultUrl(const GerritServer &server, int gerritNumber)
{
QString result = QLatin1String(p->https ? "https://" : "http://");
QString result = QLatin1String(gerritSettings().https ? "https://" : "http://");
result += server.host;
result += '/';
result += QString::number(gerritNumber);
@@ -208,7 +206,6 @@ class QueryContext : public QObject
Q_OBJECT
public:
QueryContext(const QString &query,
const std::shared_ptr<GerritParameters> &p,
const GerritServer &server,
QObject *parent = nullptr);
@@ -236,22 +233,21 @@ private:
enum { timeOutMS = 30000 };
QueryContext::QueryContext(const QString &query,
const std::shared_ptr<GerritParameters> &p,
const GerritServer &server,
QObject *parent)
: QObject(parent)
{
m_process.setUseCtrlCStub(true);
if (server.type == GerritServer::Ssh) {
m_binary = p->ssh;
m_binary = gerritSettings().ssh;
if (server.port)
m_arguments << p->portFlag << QString::number(server.port);
m_arguments << gerritSettings().portFlag << QString::number(server.port);
m_arguments << server.hostArgument() << "gerrit"
<< "query" << "--dependencies"
<< "--current-patch-set"
<< "--format=JSON" << query;
} else {
m_binary = p->curl;
m_binary = gerritSettings().curl;
const QString url = server.url(GerritServer::RestUrl) + "/changes/?q="
+ QString::fromUtf8(QUrl::toPercentEncoding(query))
+ "&o=CURRENT_REVISION&o=DETAILED_LABELS&o=DETAILED_ACCOUNTS";
@@ -338,9 +334,8 @@ void QueryContext::timeout()
m_timer.start();
}
GerritModel::GerritModel(const std::shared_ptr<GerritParameters> &p, QObject *parent)
GerritModel::GerritModel(QObject *parent)
: QStandardItemModel(0, ColumnCount, parent)
, m_parameters(p)
{
QStringList headers; // Keep in sync with GerritChange::toHtml()
headers << "#" << Git::Tr::tr("Subject") << Git::Tr::tr("Owner")
@@ -460,7 +455,7 @@ void GerritModel::refresh(const std::shared_ptr<GerritServer> &server, const QSt
realQuery += QString(" (owner:%1 OR reviewer:%1)").arg(user);
}
m_query = new QueryContext(realQuery, m_parameters, *m_server, this);
m_query = new QueryContext(realQuery, *m_server, this);
connect(m_query, &QueryContext::resultRetrieved, this, &GerritModel::resultRetrieved);
connect(m_query, &QueryContext::errorText, this, &GerritModel::errorText);
connect(m_query, &QueryContext::finished, this, &GerritModel::queryFinished);
@@ -731,8 +726,7 @@ static GerritChangePtr parseRestOutput(const QJsonObject &object, const GerritSe
return change;
}
static bool parseOutput(const std::shared_ptr<GerritParameters> &parameters,
const GerritServer &server,
static bool parseOutput(const GerritServer &server,
const QByteArray &output,
QList<GerritChangePtr> &result)
{
@@ -775,7 +769,7 @@ static bool parseOutput(const std::shared_ptr<GerritParameters> &parameters,
: parseRestOutput(object, server));
if (change->isValid()) {
if (change->url.isEmpty()) // No "canonicalWebUrl" is in gerrit.config.
change->url = defaultUrl(parameters, server, change->number);
change->url = defaultUrl(server, change->number);
result.push_back(change);
} else {
const QByteArray jsonObject = QJsonDocument(object).toJson();
@@ -844,7 +838,7 @@ bool gerritChangeLessThan(const GerritChangePtr &c1, const GerritChangePtr &c2)
void GerritModel::resultRetrieved(const QByteArray &output)
{
QList<GerritChangePtr> changes;
setState(parseOutput(m_parameters, *m_server, output, changes) ? Ok : Error);
setState(parseOutput(*m_server, output, changes) ? Ok : Error);
// Populate a hash with indices for faster access.
QHash<int, int> numberIndexHash;
@@ -910,7 +904,6 @@ void GerritModel::queryFinished()
emit refreshStateChanged(false);
}
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal
#include "gerritmodel.moc"

View File

@@ -3,14 +3,13 @@
#pragma once
#include "gerritparameters.h"
#include "gerritserver.h"
#include <QStandardItemModel>
#include <QDateTime>
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
class QueryContext;
class GerritApproval {
@@ -78,7 +77,7 @@ public:
GerritChangeRole = Qt::UserRole + 2,
SortRole = Qt::UserRole + 3
};
GerritModel(const std::shared_ptr<GerritParameters> &, QObject *parent = nullptr);
GerritModel(QObject *parent = nullptr);
~GerritModel() override;
QVariant data(const QModelIndex &index, int role) const override;
@@ -110,11 +109,9 @@ private:
const QString &serverPrefix) const;
QList<QStandardItem *> changeToRow(const GerritChangePtr &c) const;
const std::shared_ptr<GerritParameters> m_parameters;
std::shared_ptr<GerritServer> m_server;
QueryContext *m_query = nullptr;
QueryState m_state = Idle;
};
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal

View File

@@ -23,31 +23,30 @@ namespace Gerrit::Internal {
class GerritOptionsWidget : public Core::IOptionsPageWidget
{
public:
GerritOptionsWidget(const std::shared_ptr<GerritParameters> &p,
const std::function<void()> &onChanged)
: m_parameters(p)
GerritOptionsWidget(const std::function<void()> &onChanged)
{
auto hostLineEdit = new QLineEdit(p->server.host);
const GerritParameters &s = gerritSettings();
auto hostLineEdit = new QLineEdit(s.server.host);
auto userLineEdit = new QLineEdit(p->server.user.userName);
auto userLineEdit = new QLineEdit(s.server.user.userName);
auto sshChooser = new Utils::PathChooser;
sshChooser->setFilePath(p->ssh);
sshChooser->setFilePath(s.ssh);
sshChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
sshChooser->setCommandVersionArguments({"-V"});
sshChooser->setHistoryCompleter("Git.SshCommand.History");
auto curlChooser = new Utils::PathChooser;
curlChooser->setFilePath(p->curl);
curlChooser->setFilePath(s.curl);
curlChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
curlChooser->setCommandVersionArguments({"-V"});
auto portSpinBox = new QSpinBox(this);
portSpinBox->setRange(1, 65535);
portSpinBox->setValue(p->server.port);
portSpinBox->setValue(s.server.port);
auto httpsCheckBox = new QCheckBox(Git::Tr::tr("HTTPS"));
httpsCheckBox->setChecked(p->https);
httpsCheckBox->setChecked(s.https);
httpsCheckBox->setToolTip(Git::Tr::tr(
"Determines the protocol used to form a URL in case\n"
"\"canonicalWebUrl\" is not configured in the file\n"
@@ -63,14 +62,14 @@ public:
Git::Tr::tr("P&rotocol:"), httpsCheckBox
}.attachTo(this);
setOnApply([this,
hostLineEdit,
setOnApply([hostLineEdit,
userLineEdit,
sshChooser,
curlChooser,
portSpinBox,
httpsCheckBox,
onChanged] {
GerritParameters &s = gerritSettings();
GerritParameters newParameters;
newParameters.server = GerritServer(hostLineEdit->text().trimmed(),
static_cast<unsigned short>(portSpinBox->value()),
@@ -80,31 +79,27 @@ public:
newParameters.curl = curlChooser->filePath();
newParameters.https = httpsCheckBox->isChecked();
if (newParameters != *m_parameters) {
if (m_parameters->ssh == newParameters.ssh)
newParameters.portFlag = m_parameters->portFlag;
if (newParameters != s) {
if (s.ssh == newParameters.ssh)
newParameters.portFlag = s.portFlag;
else
newParameters.setPortFlagBySshType();
*m_parameters = newParameters;
m_parameters->toSettings(Core::ICore::settings());
s = newParameters;
s.toSettings();
emit onChanged();
}
});
}
private:
const std::shared_ptr<GerritParameters> &m_parameters;
};
// GerritOptionsPage
GerritOptionsPage::GerritOptionsPage(const std::shared_ptr<GerritParameters> &p,
const std::function<void()> &onChanged)
GerritOptionsPage::GerritOptionsPage(const std::function<void()> &onChanged)
{
setId("Gerrit");
setDisplayName(Git::Tr::tr("Gerrit"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
setWidgetCreator([p, onChanged] { return new GerritOptionsWidget(p, onChanged); });
setWidgetCreator([onChanged] { return new GerritOptionsWidget(onChanged); });
}
} // Gerrit::Internal

View File

@@ -7,13 +7,10 @@
namespace Gerrit::Internal {
class GerritParameters;
class GerritOptionsPage : public Core::IOptionsPage
{
public:
GerritOptionsPage(const std::shared_ptr<GerritParameters> &p,
const std::function<void()> &onChanged);
explicit GerritOptionsPage(const std::function<void()> &onChanged);
};
} // Gerrit::Internal

View File

@@ -4,6 +4,8 @@
#include "gerritparameters.h"
#include "gerritplugin.h"
#include <coreplugin/icore.h>
#include <utils/commandline.h>
#include <utils/datafromprocess.h>
#include <utils/environment.h>
@@ -14,10 +16,10 @@
#include <QDir>
#include <QStandardPaths>
using namespace Core;
using namespace Utils;
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
const char settingsGroupC[] = "Gerrit";
const char hostKeyC[] = "Host";
@@ -91,8 +93,9 @@ bool GerritParameters::equals(const GerritParameters &rhs) const
return server == rhs.server && ssh == rhs.ssh && curl == rhs.curl && https == rhs.https;
}
void GerritParameters::toSettings(QtcSettings *s) const
void GerritParameters::toSettings() const
{
QtcSettings *s = ICore::settings();
s->beginGroup(settingsGroupC);
s->setValue(hostKeyC, server.host);
s->setValue(userKeyC, server.user.userName);
@@ -104,15 +107,17 @@ void GerritParameters::toSettings(QtcSettings *s) const
s->endGroup();
}
void GerritParameters::saveQueries(QtcSettings *s) const
void GerritParameters::saveQueries() const
{
QtcSettings *s = ICore::settings();
s->beginGroup(settingsGroupC);
s->setValue(savedQueriesKeyC, savedQueries.join(','));
s->endGroup();
}
void GerritParameters::fromSettings(const QtcSettings *s)
void GerritParameters::fromSettings()
{
QtcSettings *s = ICore::settings();
const Key rootKey = Key(settingsGroupC) + '/';
server.host = s->value(rootKey + hostKeyC, GerritServer::defaultHost()).toString();
server.user.userName = s->value(rootKey + userKeyC, QString()).toString();
@@ -134,5 +139,10 @@ bool GerritParameters::isValid() const
return !server.host.isEmpty() && !server.user.userName.isEmpty() && !ssh.isEmpty();
}
} // namespace Internal
} // namespace Gerrit
GerritParameters &gerritSettings()
{
static GerritParameters theGerritSettings;
return theGerritSettings;
}
} // Gerrit::Internal

View File

@@ -7,10 +7,7 @@
#include <utils/filepath.h>
namespace Utils { class QtcSettings; }
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
class GerritParameters
{
@@ -19,9 +16,9 @@ public:
bool isValid() const;
bool equals(const GerritParameters &rhs) const;
void toSettings(Utils::QtcSettings *) const;
void saveQueries(Utils::QtcSettings *) const;
void fromSettings(const Utils::QtcSettings *);
void toSettings() const;
void saveQueries() const;
void fromSettings();
void setPortFlagBySshType();
friend bool operator==(const GerritParameters &p1, const GerritParameters &p2)
@@ -37,5 +34,6 @@ public:
QString portFlag;
};
} // namespace Internal
} // namespace Gerrit
GerritParameters &gerritSettings();
} // Gerrit::Internal

View File

@@ -153,13 +153,11 @@ void FetchContext::checkout()
}
GerritPlugin::GerritPlugin()
: m_parameters(new GerritParameters)
, m_server(new GerritServer)
: m_server(new GerritServer)
{
m_parameters->fromSettings(ICore::settings());
gerritSettings().fromSettings();
m_gerritOptionsPage = new GerritOptionsPage(m_parameters,
[this] {
m_gerritOptionsPage = new GerritOptionsPage([this] {
if (m_dialog)
m_dialog->scheduleUpdateRemotes();
});
@@ -206,7 +204,7 @@ void GerritPlugin::addToLocator(CommandLocator *locator)
void GerritPlugin::push(const FilePath &topLevel)
{
// QScopedPointer is required to delete the dialog when leaving the function
GerritPushDialog dialog(topLevel, m_reviewers, m_parameters, ICore::dialogParent());
GerritPushDialog dialog(topLevel, m_reviewers, ICore::dialogParent());
const QString initErrorMessage = dialog.initErrorMessage();
if (!initErrorMessage.isEmpty()) {
@@ -231,13 +229,13 @@ static FilePath currentRepository()
void GerritPlugin::openView()
{
if (m_dialog.isNull()) {
while (!m_parameters->isValid()) {
while (!gerritSettings().isValid()) {
QMessageBox::warning(Core::ICore::dialogParent(), Git::Tr::tr("Error"),
Git::Tr::tr("Invalid Gerrit configuration. Host, user and ssh binary are mandatory."));
if (!ICore::showOptionsDialog("Gerrit"))
return;
}
GerritDialog *gd = new GerritDialog(m_parameters, m_server, currentRepository(), ICore::dialogParent());
GerritDialog *gd = new GerritDialog(m_server, currentRepository(), ICore::dialogParent());
gd->setModal(false);
ICore::registerWindow(gd, Context("Git.Gerrit"));
connect(gd, &GerritDialog::fetchDisplay, this,
@@ -287,7 +285,7 @@ void GerritPlugin::fetch(const std::shared_ptr<GerritChange> &change, int mode)
FilePath repository;
bool verifiedRepository = false;
if (m_dialog && m_parameters && m_dialog->repositoryPath().exists())
if (m_dialog && m_dialog->repositoryPath().exists())
repository = m_dialog->repositoryPath();
if (!repository.isEmpty()) {

View File

@@ -17,12 +17,10 @@ class CommandLocator;
namespace VcsBase { class VcsBasePluginState; }
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
class GerritChange;
class GerritDialog;
class GerritParameters;
class GerritServer;
class GerritOptionsPage;
@@ -54,7 +52,6 @@ private:
Utils::FilePath findLocalRepository(const QString &project, const QString &branch) const;
void fetch(const std::shared_ptr<GerritChange> &change, int mode);
std::shared_ptr<GerritParameters> m_parameters;
std::shared_ptr<GerritServer> m_server;
QPointer<GerritDialog> m_dialog;
Core::Command *m_gerritCommand = nullptr;
@@ -63,5 +60,4 @@ private:
GerritOptionsPage *m_gerritOptionsPage = nullptr;
};
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal

View File

@@ -25,8 +25,7 @@
using namespace Git::Internal;
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
static const int ReasonableDistance = 100;
@@ -108,7 +107,6 @@ void GerritPushDialog::initRemoteBranches()
GerritPushDialog::GerritPushDialog(const Utils::FilePath &workingDir,
const QString &reviewerList,
std::shared_ptr<GerritParameters> parameters,
QWidget *parent)
: QDialog(parent)
, m_localBranchComboBox(new BranchComboBox)
@@ -154,7 +152,6 @@ GerritPushDialog::GerritPushDialog(const Utils::FilePath &workingDir,
}.attachTo(this);
m_remoteComboBox->setRepository(workingDir);
m_remoteComboBox->setParameters(parameters);
m_remoteComboBox->setAllowDups(true);
auto delegate = new PushItemDelegate(m_commitView);
@@ -419,5 +416,4 @@ QString GerritPushDialog::reviewers() const
return m_reviewersLineEdit->text();
}
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal

View File

@@ -19,11 +19,9 @@ QT_END_NAMESPACE
namespace Git::Internal { class LogChangeWidget; }
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
class BranchComboBox;
class GerritParameters;
class GerritRemoteChooser;
class GerritPushDialog : public QDialog
@@ -32,7 +30,7 @@ class GerritPushDialog : public QDialog
public:
GerritPushDialog(const Utils::FilePath &workingDir, const QString &reviewerList,
std::shared_ptr<GerritParameters> parameters, QWidget *parent);
QWidget *parent);
QString selectedCommit() const;
QString selectedRemoteName() const;
@@ -76,6 +74,4 @@ private:
bool m_currentSupportsWip = false;
};
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal

View File

@@ -51,11 +51,6 @@ void GerritRemoteChooser::setRepository(const FilePath &repository)
m_repository = repository;
}
void GerritRemoteChooser::setParameters(std::shared_ptr<GerritParameters> parameters)
{
m_parameters = parameters;
}
void GerritRemoteChooser::setFallbackEnabled(bool value)
{
m_enableFallback = value;
@@ -79,7 +74,7 @@ bool GerritRemoteChooser::setCurrentRemote(const QString &remoteName)
bool GerritRemoteChooser::updateRemotes(bool forceReload)
{
QTC_ASSERT(!m_repository.isEmpty() || !m_parameters, return false);
QTC_ASSERT(!m_repository.isEmpty(), return false);
m_updatingRemotes = true;
m_remoteComboBox->clear();
m_remotes.clear();
@@ -88,12 +83,12 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload)
Git::Internal::gitClient().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))
if (!server.fillFromRemote(mapIt.value(), forceReload))
continue;
addRemote(server, mapIt.key());
}
if (m_enableFallback)
addRemote(m_parameters->server, Git::Tr::tr("Fallback"));
addRemote(gerritSettings().server, Git::Tr::tr("Fallback"));
m_remoteComboBox->setEnabled(m_remoteComboBox->count() > 1);
m_updatingRemotes = false;
handleRemoteChanged();

View File

@@ -16,8 +16,6 @@
namespace Gerrit {
namespace Internal {
class GerritParameters;
class GerritRemoteChooser : public QWidget
{
Q_OBJECT
@@ -25,7 +23,6 @@ class GerritRemoteChooser : public QWidget
public:
GerritRemoteChooser(QWidget *parent = nullptr);
void setRepository(const Utils::FilePath &repository);
void setParameters(std::shared_ptr<GerritParameters> parameters);
void setFallbackEnabled(bool value);
void setAllowDups(bool value);
bool setCurrentRemote(const QString &remoteName);
@@ -43,7 +40,6 @@ private:
void handleRemoteChanged();
Utils::FilePath m_repository;
std::shared_ptr<GerritParameters> m_parameters;
QComboBox *m_remoteComboBox = nullptr;
QToolButton *m_resetRemoteButton = nullptr;
bool m_updatingRemotes = false;

View File

@@ -25,8 +25,7 @@ using namespace Git::Internal;
using namespace Utils;
using namespace VcsBase;
namespace Gerrit {
namespace Internal {
namespace Gerrit::Internal {
static const char defaultHostC[] = "codereview.qt-project.org";
static const char accountUrlC[] = "/accounts/self";
@@ -115,9 +114,7 @@ QString GerritServer::url(UrlType urlType) const
return res;
}
bool GerritServer::fillFromRemote(const QString &remote,
const GerritParameters &parameters,
bool forceReload)
bool GerritServer::fillFromRemote(const QString &remote, bool forceReload)
{
const GitRemote r(remote);
if (!r.isValid)
@@ -136,11 +133,11 @@ bool GerritServer::fillFromRemote(const QString &remote,
return false;
host = r.host;
port = r.port;
user.userName = r.userName.isEmpty() ? parameters.server.user.userName : r.userName;
user.userName = r.userName.isEmpty() ? gerritSettings().server.user.userName : r.userName;
if (type == GerritServer::Ssh) {
return resolveVersion(parameters, forceReload);
return resolveVersion(forceReload);
}
curlBinary = parameters.curl;
curlBinary = gerritSettings().curl;
if (curlBinary.isEmpty() || !curlBinary.exists())
return false;
const StoredHostValidity validity = forceReload ? Invalid : loadSettings();
@@ -152,7 +149,7 @@ bool GerritServer::fillFromRemote(const QString &remote,
// (can be http://example.net/review)
ascendPath();
if (resolveRoot()) {
if (!resolveVersion(parameters, forceReload))
if (!resolveVersion(forceReload))
return false;
saveSettings(Valid);
return true;
@@ -161,7 +158,7 @@ bool GerritServer::fillFromRemote(const QString &remote,
case NotGerrit:
return false;
case Valid:
return resolveVersion(parameters, false);
return resolveVersion(false);
}
return true;
}
@@ -307,8 +304,9 @@ bool GerritServer::resolveRoot()
return false;
}
bool GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
bool GerritServer::resolveVersion(bool forceReload)
{
const GerritParameters &p = gerritSettings();
QtcSettings *settings = Core::ICore::settings();
const Key fullVersionKey = "Gerrit/" + keyFromString(host) + '/' + versionKey;
version = settings->value(fullVersionKey).toString();
@@ -346,5 +344,4 @@ bool GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
return true;
}
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal

View File

@@ -5,10 +5,7 @@
#include <utils/filepath.h>
namespace Gerrit {
namespace Internal {
class GerritParameters;
namespace Gerrit::Internal {
class GerritUser
{
@@ -52,7 +49,7 @@ public:
static QString defaultHost();
QString hostArgument() const;
QString url(UrlType urlType = DefaultUrl) const;
bool fillFromRemote(const QString &remote, const GerritParameters &parameters, bool forceReload);
bool fillFromRemote(const QString &remote, bool forceReload);
int testConnection();
QStringList curlArguments() const;
@@ -72,8 +69,7 @@ private:
bool setupAuthentication();
bool ascendPath();
bool resolveRoot();
bool resolveVersion(const GerritParameters &p, bool forceReload);
bool resolveVersion(bool forceReload);
};
} // namespace Internal
} // namespace Gerrit
} // Gerrit::Internal