forked from qt-creator/qt-creator
Utils: Introduce HostOsInfo class.
The class' member functions are intended to be used instead of the Q_OS_* macros in all contexts where the latter are not syntactically required. This lowers the likelihood of changes made on one platform breaking the build on another, e.g. due to the code model missing symbols in #ifdef'ed out code when refactoring. Change-Id: I4a54788591b4c8f8d589b8368a6c683d4155c9fa Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#else
|
||||
# include <utils/environment.h>
|
||||
#endif
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
@@ -72,16 +73,16 @@ static inline QString detectSsh()
|
||||
#endif
|
||||
if (!ssh.isEmpty())
|
||||
return ssh;
|
||||
#ifdef Q_OS_WIN // 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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ssh;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include <coreplugin/variablemanager.h>
|
||||
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
@@ -1441,7 +1442,6 @@ VcsBase::Command *GitClient::executeGit(const QString &workingDirectory,
|
||||
|
||||
QProcessEnvironment GitClient::processEnvironment() const
|
||||
{
|
||||
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString gitPath = settings()->stringValue(GitSettings::pathKey);
|
||||
if (!gitPath.isEmpty()) {
|
||||
@@ -1449,10 +1449,10 @@ QProcessEnvironment GitClient::processEnvironment() const
|
||||
gitPath += environment.value(QLatin1String("PATH"));
|
||||
environment.insert(QLatin1String("PATH"), gitPath);
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
if (settings()->boolValue(GitSettings::winSetHomeEnvironmentKey))
|
||||
if (Utils::HostOsInfo::isWindowsHost()
|
||||
&& settings()->boolValue(GitSettings::winSetHomeEnvironmentKey)) {
|
||||
environment.insert(QLatin1String("HOME"), QDir::toNativeSeparators(QDir::homePath()));
|
||||
#endif // Q_OS_WIN
|
||||
}
|
||||
// Set up SSH and C locale (required by git using perl).
|
||||
VcsBase::VcsBasePlugin::setProcessEnvironment(&environment, false);
|
||||
return environment;
|
||||
@@ -1659,15 +1659,16 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
|
||||
const QString &gitBinDirectory,
|
||||
bool silent)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
// Launch 'wish' shell from git binary directory with the gitk located there
|
||||
const QString binary = gitBinDirectory + QLatin1String("/wish");
|
||||
QStringList arguments(gitBinDirectory + QLatin1String("/gitk"));
|
||||
#else
|
||||
// Simple: Run gitk from binary path
|
||||
const QString binary = gitBinDirectory + QLatin1String("/gitk");
|
||||
QString binary;
|
||||
QStringList arguments;
|
||||
#endif
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
// Launch 'wish' shell from git binary directory with the gitk located there
|
||||
binary = gitBinDirectory + QLatin1String("/wish");
|
||||
arguments << (gitBinDirectory + QLatin1String("/gitk"));
|
||||
} else {
|
||||
// Simple: Run gitk from binary path
|
||||
binary = gitBinDirectory + QLatin1String("/gitk");
|
||||
}
|
||||
VcsBase::VcsBaseOutputWindow *outwin = VcsBase::VcsBaseOutputWindow::instance();
|
||||
const QString gitkOpts = settings()->stringValue(GitSettings::gitkOptionsKey);
|
||||
if (!gitkOpts.isEmpty())
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "gitsettings.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -54,11 +55,7 @@ GitSettings::GitSettings()
|
||||
setSettingsGroup(QLatin1String("Git"));
|
||||
|
||||
declareKey(binaryPathKey, QLatin1String("git"));
|
||||
#ifdef Q_OS_WIN
|
||||
declareKey(timeoutKey, 60);
|
||||
#else
|
||||
declareKey(timeoutKey, 30);
|
||||
#endif
|
||||
declareKey(timeoutKey, Utils::HostOsInfo::isWindowsHost() ? 60 : 30);
|
||||
declareKey(pathKey, QString());
|
||||
declareKey(pullRebaseKey, false);
|
||||
declareKey(omitAnnotationDateKey, false);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "gitclient.h"
|
||||
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
@@ -51,19 +52,19 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
#ifdef Q_OS_WIN
|
||||
const QByteArray currentHome = qgetenv("HOME");
|
||||
const QString toolTip
|
||||
= tr("Set the environment variable HOME to '%1'\n(%2).\n"
|
||||
"This causes msysgit to look for the SSH-keys in that location\n"
|
||||
"instead of its installation directory when run outside git bash.").
|
||||
arg(QDir::homePath(),
|
||||
currentHome.isEmpty() ? tr("not currently set") :
|
||||
tr("currently set to '%1'").arg(QString::fromLocal8Bit(currentHome)));
|
||||
m_ui.winHomeCheckBox->setToolTip(toolTip);
|
||||
#else
|
||||
m_ui.winHomeCheckBox->setVisible(false);
|
||||
#endif
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
const QByteArray currentHome = qgetenv("HOME");
|
||||
const QString toolTip
|
||||
= tr("Set the environment variable HOME to '%1'\n(%2).\n"
|
||||
"This causes msysgit to look for the SSH-keys in that location\n"
|
||||
"instead of its installation directory when run outside git bash.").
|
||||
arg(QDir::homePath(),
|
||||
currentHome.isEmpty() ? tr("not currently set") :
|
||||
tr("currently set to '%1'").arg(QString::fromLocal8Bit(currentHome)));
|
||||
m_ui.winHomeCheckBox->setToolTip(toolTip);
|
||||
} else {
|
||||
m_ui.winHomeCheckBox->setVisible(false);
|
||||
}
|
||||
m_ui.repBrowserCommandPathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||
m_ui.repBrowserCommandPathChooser->setPromptDialogTitle(tr("Git Repository Browser Command"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user