Commit 351f6b8f authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

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's avatarTobias Hunger <tobias.hunger@qt.io>
parent f3f5a16f
......@@ -58,13 +58,14 @@ static inline QString detectSsh()
const QByteArray gitSsh = qgetenv("GIT_SSH");
if (!gitSsh.isEmpty())
return QString::fromLocal8Bit(gitSsh);
QString ssh = QStandardPaths::findExecutable(defaultSshC);
const QString defaultSsh = Utils::HostOsInfo::withExecutableSuffix(defaultSshC);
QString ssh = QStandardPaths::findExecutable(defaultSsh);
if (!ssh.isEmpty())
return ssh;
if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
Utils::FileName path = GerritPlugin::gitBinDirectory();
if (!path.isEmpty())
ssh = path.appendPath(defaultSshC).toString();
ssh = path.appendPath(defaultSsh).toString();
}
return ssh;
}
......@@ -186,7 +187,7 @@ void GerritParameters::fromSettings(const QSettings *s)
savedQueries = s->value(rootKey + savedQueriesKeyC, QString()).toString()
.split(',');
https = s->value(rootKey + httpsKeyC, QVariant(true)).toBool();
if (ssh.isEmpty())
if (ssh.isEmpty() || !QFile::exists(ssh))
ssh = detectSsh();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment