forked from qt-creator/qt-creator
Gerrit: Skip non-Gerrit remotes in Push to Gerrit dialog
In my case, I have a second remote gitlab which was always selected instead the expected remote gerrit. Change-Id: I7860ea4743dbfa5d1fd4375821474950549e0600 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
65f5fde2e6
commit
e3bb18f8e1
@@ -157,8 +157,7 @@ bool GerritServer::fillFromRemote(const QString &remote,
|
|||||||
port = r.port;
|
port = r.port;
|
||||||
user.userName = r.userName.isEmpty() ? parameters.server.user.userName : r.userName;
|
user.userName = r.userName.isEmpty() ? parameters.server.user.userName : r.userName;
|
||||||
if (type == GerritServer::Ssh) {
|
if (type == GerritServer::Ssh) {
|
||||||
resolveVersion(parameters, forceReload);
|
return resolveVersion(parameters, forceReload);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
curlBinary = parameters.curl;
|
curlBinary = parameters.curl;
|
||||||
if (curlBinary.isEmpty() || !curlBinary.exists())
|
if (curlBinary.isEmpty() || !curlBinary.exists())
|
||||||
@@ -172,7 +171,8 @@ bool GerritServer::fillFromRemote(const QString &remote,
|
|||||||
// (can be http://example.net/review)
|
// (can be http://example.net/review)
|
||||||
ascendPath();
|
ascendPath();
|
||||||
if (resolveRoot()) {
|
if (resolveRoot()) {
|
||||||
resolveVersion(parameters, forceReload);
|
if (!resolveVersion(parameters, forceReload))
|
||||||
|
return false;
|
||||||
saveSettings(Valid);
|
saveSettings(Valid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -180,8 +180,7 @@ bool GerritServer::fillFromRemote(const QString &remote,
|
|||||||
case NotGerrit:
|
case NotGerrit:
|
||||||
return false;
|
return false;
|
||||||
case Valid:
|
case Valid:
|
||||||
resolveVersion(parameters, false);
|
return resolveVersion(parameters, false);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -332,14 +331,14 @@ bool GerritServer::resolveRoot()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
bool GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
||||||
{
|
{
|
||||||
static GitClient *const client = GitClient::instance();
|
static GitClient *const client = GitClient::instance();
|
||||||
QSettings *settings = Core::ICore::settings();
|
QSettings *settings = Core::ICore::settings();
|
||||||
const QString fullVersionKey = "Gerrit/" + host + '/' + versionKey;
|
const QString fullVersionKey = "Gerrit/" + host + '/' + versionKey;
|
||||||
version = settings->value(fullVersionKey).toString();
|
version = settings->value(fullVersionKey).toString();
|
||||||
if (!version.isEmpty() && !forceReload)
|
if (!version.isEmpty() && !forceReload)
|
||||||
return;
|
return true;
|
||||||
if (type == Ssh) {
|
if (type == Ssh) {
|
||||||
QtcProcess proc;
|
QtcProcess proc;
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
@@ -350,6 +349,8 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
|||||||
QString stdOut = proc.stdOut().trimmed();
|
QString stdOut = proc.stdOut().trimmed();
|
||||||
stdOut.remove("gerrit version ");
|
stdOut.remove("gerrit version ");
|
||||||
version = stdOut;
|
version = stdOut;
|
||||||
|
if (version.isEmpty())
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC);
|
const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC);
|
||||||
QtcProcess proc;
|
QtcProcess proc;
|
||||||
@@ -360,7 +361,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
|||||||
if (proc.result() == ProcessResult::FinishedWithSuccess) {
|
if (proc.result() == ProcessResult::FinishedWithSuccess) {
|
||||||
QString output = proc.stdOut();
|
QString output = proc.stdOut();
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())
|
||||||
return;
|
return false;
|
||||||
output.remove(0, output.indexOf('\n')); // Strip first line
|
output.remove(0, output.indexOf('\n')); // Strip first line
|
||||||
output.remove('\n');
|
output.remove('\n');
|
||||||
output.remove('"');
|
output.remove('"');
|
||||||
@@ -368,6 +369,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
settings->setValue(fullVersionKey, version);
|
settings->setValue(fullVersionKey, version);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -94,7 +94,7 @@ private:
|
|||||||
bool setupAuthentication();
|
bool setupAuthentication();
|
||||||
bool ascendPath();
|
bool ascendPath();
|
||||||
bool resolveRoot();
|
bool resolveRoot();
|
||||||
void resolveVersion(const GerritParameters &p, bool forceReload);
|
bool resolveVersion(const GerritParameters &p, bool forceReload);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user