forked from qt-creator/qt-creator
VCS: Use qtcEnvironmentVariable* instead of qEnvironmentVariable*
And instead of qgetenv. Takes Qt Creator's setting at "Environment > System > Environment" into account, which makes it easier on some platforms to set them (e.g. macOS), can be configured differently in different settings paths, and potentially can be changed at runtime (depending on usage). Change-Id: I364e5b663353f37121279a58f4a9fd514cddbbf0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "gerritplugin.h"
|
||||
|
||||
#include <utils/commandline.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/pathchooser.h>
|
||||
|
||||
@@ -81,7 +82,7 @@ static FilePath detectApp(const QString &defaultExe)
|
||||
|
||||
static FilePath detectSsh()
|
||||
{
|
||||
const QString gitSsh = qEnvironmentVariable("GIT_SSH");
|
||||
const QString gitSsh = qtcEnvironmentVariable("GIT_SSH");
|
||||
if (!gitSsh.isEmpty())
|
||||
return FilePath::fromString(gitSsh);
|
||||
return detectApp("ssh");
|
||||
|
@@ -2244,11 +2244,10 @@ Environment GitClient::processEnvironment() const
|
||||
environment.prependOrSetPath(FilePath::fromUserInput(gitPath));
|
||||
if (HostOsInfo::isWindowsHost() && settings().winSetHomeEnvironment.value()) {
|
||||
QString homePath;
|
||||
if (qEnvironmentVariableIsEmpty("HOMESHARE")) {
|
||||
if (qtcEnvironmentVariableIsEmpty("HOMESHARE")) {
|
||||
homePath = QDir::toNativeSeparators(QDir::homePath());
|
||||
} else {
|
||||
homePath = QString::fromLocal8Bit(qgetenv("HOMEDRIVE"))
|
||||
+ QString::fromLocal8Bit(qgetenv("HOMEPATH"));
|
||||
homePath = qtcEnvironmentVariable("HOMEDRIVE") + qtcEnvironmentVariable("HOMEPATH");
|
||||
}
|
||||
environment.set("HOME", homePath);
|
||||
}
|
||||
|
@@ -79,14 +79,14 @@ GitSettings::GitSettings()
|
||||
winSetHomeEnvironment.setDefaultValue(true);
|
||||
winSetHomeEnvironment.setLabelText(tr("Set \"HOME\" environment variable"));
|
||||
if (HostOsInfo::isWindowsHost()) {
|
||||
const QByteArray currentHome = qgetenv("HOME");
|
||||
const QString currentHome = qtcEnvironmentVariable("HOME");
|
||||
const QString toolTip
|
||||
= tr("Set the environment variable HOME to \"%1\"\n(%2).\n"
|
||||
"This causes Git 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)));
|
||||
= tr("Set the environment variable HOME to \"%1\"\n(%2).\n"
|
||||
"This causes Git 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(currentHome));
|
||||
winSetHomeEnvironment.setToolTip(toolTip);
|
||||
} else {
|
||||
winSetHomeEnvironment.setVisible(false);
|
||||
|
@@ -47,9 +47,9 @@ namespace Internal {
|
||||
// Return default for the ssh-askpass command (default to environment)
|
||||
static QString sshPasswordPromptDefault()
|
||||
{
|
||||
const QByteArray envSetting = qgetenv("SSH_ASKPASS");
|
||||
const QString envSetting = qtcEnvironmentVariable("SSH_ASKPASS");
|
||||
if (!envSetting.isEmpty())
|
||||
return QString::fromLocal8Bit(envSetting);
|
||||
return envSetting;
|
||||
if (HostOsInfo::isWindowsHost())
|
||||
return QLatin1String("win-ssh-askpass");
|
||||
return QLatin1String("ssh-askpass");
|
||||
|
Reference in New Issue
Block a user