Gerrit: Improve default SSH lookup

* Append exe suffix
* Detect also if not found (for example, when upgrading from msysGit to
  Git for Windows).

Change-Id: I9c47f0f4e54e957e21e224f100c2959dc1884ec2
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2017-02-23 15:01:10 +02:00
committed by Orgad Shaneh
parent f3f5a16f27
commit 351f6b8f11

View File

@@ -58,13 +58,14 @@ static inline QString detectSsh()
const QByteArray gitSsh = qgetenv("GIT_SSH"); const QByteArray gitSsh = qgetenv("GIT_SSH");
if (!gitSsh.isEmpty()) if (!gitSsh.isEmpty())
return QString::fromLocal8Bit(gitSsh); return QString::fromLocal8Bit(gitSsh);
QString ssh = QStandardPaths::findExecutable(defaultSshC); const QString defaultSsh = Utils::HostOsInfo::withExecutableSuffix(defaultSshC);
QString ssh = QStandardPaths::findExecutable(defaultSsh);
if (!ssh.isEmpty()) if (!ssh.isEmpty())
return ssh; return ssh;
if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found. if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
Utils::FileName path = GerritPlugin::gitBinDirectory(); Utils::FileName path = GerritPlugin::gitBinDirectory();
if (!path.isEmpty()) if (!path.isEmpty())
ssh = path.appendPath(defaultSshC).toString(); ssh = path.appendPath(defaultSsh).toString();
} }
return ssh; return ssh;
} }
@@ -186,7 +187,7 @@ void GerritParameters::fromSettings(const QSettings *s)
savedQueries = s->value(rootKey + savedQueriesKeyC, QString()).toString() savedQueries = s->value(rootKey + savedQueriesKeyC, QString()).toString()
.split(','); .split(',');
https = s->value(rootKey + httpsKeyC, QVariant(true)).toBool(); https = s->value(rootKey + httpsKeyC, QVariant(true)).toBool();
if (ssh.isEmpty()) if (ssh.isEmpty() || !QFile::exists(ssh))
ssh = detectSsh(); ssh = detectSsh();
} }