forked from qt-creator/qt-creator
Gerrit: Replace bool argument with an enum, and merge url getters
Change-Id: I82035b37de31830f26297944ea0fce8b898201a4 Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
45ffa75054
commit
45a84ea6b5
@@ -200,8 +200,9 @@ QString GerritChange::filterString() const
|
||||
|
||||
QStringList GerritChange::gitFetchArguments(const GerritServer &server) const
|
||||
{
|
||||
const QString url = currentPatchSet.url.isEmpty() ? server.url(true) + '/' + project
|
||||
: currentPatchSet.url;
|
||||
const QString url = currentPatchSet.url.isEmpty()
|
||||
? server.url(GerritServer::UrlWithHttpUser) + '/' + project
|
||||
: currentPatchSet.url;
|
||||
return {"fetch", url, currentPatchSet.ref};
|
||||
}
|
||||
|
||||
@@ -271,7 +272,7 @@ QueryContext::QueryContext(const QString &query,
|
||||
<< "--format=JSON" << query;
|
||||
} else {
|
||||
m_binary = p->curl;
|
||||
const QString url = server.restUrl() + "/changes/?q="
|
||||
const QString url = server.url(GerritServer::RestUrl) + "/changes/?q="
|
||||
+ QString::fromUtf8(QUrl::toPercentEncoding(query))
|
||||
+ "&o=CURRENT_REVISION&o=DETAILED_LABELS&o=DETAILED_ACCOUNTS";
|
||||
m_arguments = GerritServer::curlArguments() << url;
|
||||
|
||||
@@ -152,7 +152,7 @@ QString GerritServer::hostArgument() const
|
||||
return user.userName.isEmpty() ? host : (user.userName + '@' + host);
|
||||
}
|
||||
|
||||
QString GerritServer::url(bool withHttpUser) const
|
||||
QString GerritServer::url(UrlType urlType) const
|
||||
{
|
||||
QString protocol;
|
||||
switch (type) {
|
||||
@@ -161,22 +161,17 @@ QString GerritServer::url(bool withHttpUser) const
|
||||
case Https: protocol = "https"; break;
|
||||
}
|
||||
QString res = protocol + "://";
|
||||
if (type == Ssh || withHttpUser)
|
||||
if (type == Ssh || urlType != DefaultUrl)
|
||||
res += hostArgument();
|
||||
else
|
||||
res += host;
|
||||
if (port)
|
||||
res += ':' + QString::number(port);
|
||||
if (type != Ssh)
|
||||
if (type != Ssh) {
|
||||
res += rootPath;
|
||||
return res;
|
||||
}
|
||||
|
||||
QString GerritServer::restUrl() const
|
||||
{
|
||||
QString res = url(true);
|
||||
if (type != Ssh && authenticated)
|
||||
res += "/a";
|
||||
if (authenticated && urlType == RestUrl)
|
||||
res += "/a";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -238,7 +233,7 @@ QStringList GerritServer::curlArguments()
|
||||
int GerritServer::testConnection()
|
||||
{
|
||||
static Git::Internal::GitClient *const client = Git::Internal::GitPlugin::client();
|
||||
const QStringList arguments = curlArguments() << (restUrl() + accountUrlC);
|
||||
const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC);
|
||||
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
|
||||
QString(), FileName::fromString(curlBinary), arguments,
|
||||
Core::ShellCommand::NoOutput);
|
||||
|
||||
@@ -54,12 +54,18 @@ public:
|
||||
Ssh
|
||||
};
|
||||
|
||||
enum UrlType
|
||||
{
|
||||
DefaultUrl,
|
||||
UrlWithHttpUser,
|
||||
RestUrl
|
||||
};
|
||||
|
||||
GerritServer();
|
||||
GerritServer(const QString &host, unsigned short port, const QString &userName, HostType type);
|
||||
bool operator==(const GerritServer &other) const;
|
||||
QString hostArgument() const;
|
||||
QString url(bool withHttpUser = false) const;
|
||||
QString restUrl() const;
|
||||
QString url(UrlType urlType = DefaultUrl) const;
|
||||
bool fillFromRemote(const QString &remote, const GerritParameters ¶meters);
|
||||
int testConnection();
|
||||
static QStringList curlArguments();
|
||||
|
||||
Reference in New Issue
Block a user