Git: Factor out resolving of bin directory on Windows

Change-Id: Ifbafa0f5cb8329faedfd1da3674b87e46001acc3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2014-07-16 00:46:07 +03:00
committed by Orgad Shaneh
parent 36d2f47dcc
commit 54db877297
5 changed files with 32 additions and 8 deletions

View File

@@ -73,14 +73,9 @@ static inline QString detectSsh()
if (!ssh.isEmpty())
return ssh;
if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
const QString git = GerritPlugin::gitBinary();
if (!git.isEmpty()) {
// Is 'git\cmd' in the path (folder containing .bats)?
QString path = QFileInfo(git).absolutePath();
if (path.endsWith(QLatin1String("cmd"), Qt::CaseInsensitive))
path.replace(path.size() - 3, 3, QLatin1String("bin"));
ssh = path + QLatin1Char('/') + QLatin1String(defaultSshC);
}
Utils::FileName path = GerritPlugin::gitBinDirectory();
if (!path.isEmpty())
ssh = path.appendPath(QLatin1String(defaultSshC)).toString();
}
return ssh;
}