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:
Andre Hartmann
2022-03-25 14:02:19 +01:00
committed by André Hartmann
parent 65f5fde2e6
commit e3bb18f8e1
2 changed files with 11 additions and 9 deletions

View File

@@ -157,8 +157,7 @@ bool GerritServer::fillFromRemote(const QString &remote,
port = r.port;
user.userName = r.userName.isEmpty() ? parameters.server.user.userName : r.userName;
if (type == GerritServer::Ssh) {
resolveVersion(parameters, forceReload);
return true;
return resolveVersion(parameters, forceReload);
}
curlBinary = parameters.curl;
if (curlBinary.isEmpty() || !curlBinary.exists())
@@ -172,7 +171,8 @@ bool GerritServer::fillFromRemote(const QString &remote,
// (can be http://example.net/review)
ascendPath();
if (resolveRoot()) {
resolveVersion(parameters, forceReload);
if (!resolveVersion(parameters, forceReload))
return false;
saveSettings(Valid);
return true;
}
@@ -180,8 +180,7 @@ bool GerritServer::fillFromRemote(const QString &remote,
case NotGerrit:
return false;
case Valid:
resolveVersion(parameters, false);
return true;
return resolveVersion(parameters, false);
}
return true;
}
@@ -332,14 +331,14 @@ bool GerritServer::resolveRoot()
return false;
}
void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
bool GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
{
static GitClient *const client = GitClient::instance();
QSettings *settings = Core::ICore::settings();
const QString fullVersionKey = "Gerrit/" + host + '/' + versionKey;
version = settings->value(fullVersionKey).toString();
if (!version.isEmpty() && !forceReload)
return;
return true;
if (type == Ssh) {
QtcProcess proc;
QStringList arguments;
@@ -350,6 +349,8 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
QString stdOut = proc.stdOut().trimmed();
stdOut.remove("gerrit version ");
version = stdOut;
if (version.isEmpty())
return false;
} else {
const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC);
QtcProcess proc;
@@ -360,7 +361,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
if (proc.result() == ProcessResult::FinishedWithSuccess) {
QString output = proc.stdOut();
if (output.isEmpty())
return;
return false;
output.remove(0, output.indexOf('\n')); // Strip first line
output.remove('\n');
output.remove('"');
@@ -368,6 +369,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
}
}
settings->setValue(fullVersionKey, version);
return true;
}
} // namespace Internal

View File

@@ -94,7 +94,7 @@ private:
bool setupAuthentication();
bool ascendPath();
bool resolveRoot();
void resolveVersion(const GerritParameters &p, bool forceReload);
bool resolveVersion(const GerritParameters &p, bool forceReload);
};
} // namespace Internal