forked from qt-creator/qt-creator
Git: Cleanup gitExecutable()
Using expected removes a bunch of handling code. Change-Id: Id524912d82aa693fbb39c7e7fa34abd77153f92e Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -929,7 +929,7 @@ void GitClient::requestReload(const QString &documentId, const FilePath &source,
|
|||||||
QTC_ASSERT(document, return);
|
QTC_ASSERT(document, return);
|
||||||
GitBaseDiffEditorController *controller = factory(document);
|
GitBaseDiffEditorController *controller = factory(document);
|
||||||
QTC_ASSERT(controller, return);
|
QTC_ASSERT(controller, return);
|
||||||
controller->setVcsBinary(settings().gitExecutable());
|
controller->setVcsBinary(settings().gitExecutable().value_or(FilePath{}));
|
||||||
controller->setProcessEnvironment(processEnvironment());
|
controller->setProcessEnvironment(processEnvironment());
|
||||||
controller->setWorkingDirectory(workingDirectory);
|
controller->setWorkingDirectory(workingDirectory);
|
||||||
|
|
||||||
@@ -2546,11 +2546,7 @@ bool GitClient::launchGitBash(const FilePath &workingDirectory)
|
|||||||
|
|
||||||
FilePath GitClient::vcsBinary() const
|
FilePath GitClient::vcsBinary() const
|
||||||
{
|
{
|
||||||
bool ok;
|
return settings().gitExecutable().value_or(FilePath{});
|
||||||
Utils::FilePath binary = settings().gitExecutable(&ok);
|
|
||||||
if (!ok)
|
|
||||||
return {};
|
|
||||||
return binary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns first line from log and removes it
|
// returns first line from log and removes it
|
||||||
|
@@ -409,11 +409,9 @@ void GitPluginPrivate::onApplySettings()
|
|||||||
{
|
{
|
||||||
emit configurationChanged();
|
emit configurationChanged();
|
||||||
updateRepositoryBrowserAction();
|
updateRepositoryBrowserAction();
|
||||||
bool gitFoundOk;
|
const expected_str<FilePath> result = settings().gitExecutable();
|
||||||
QString errorMessage;
|
if (!result) {
|
||||||
settings().gitExecutable(&gitFoundOk, &errorMessage);
|
QTimer::singleShot(0, this, [errorMessage = result.error()] {
|
||||||
if (!gitFoundOk) {
|
|
||||||
QTimer::singleShot(0, this, [errorMessage] {
|
|
||||||
AsynchronousMessageBox::warning(Tr::tr("Git Settings"), errorMessage);
|
AsynchronousMessageBox::warning(Tr::tr("Git Settings"), errorMessage);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -164,14 +164,8 @@ GitSettings::GitSettings()
|
|||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
|
expected_str<FilePath> GitSettings::gitExecutable() const
|
||||||
{
|
{
|
||||||
// Locate binary in path if one is specified, otherwise default to pathless binary.
|
|
||||||
if (ok)
|
|
||||||
*ok = true;
|
|
||||||
if (errorMessage)
|
|
||||||
errorMessage->clear();
|
|
||||||
|
|
||||||
if (tryResolve) {
|
if (tryResolve) {
|
||||||
resolvedBinPath = binaryPath();
|
resolvedBinPath = binaryPath();
|
||||||
if (!resolvedBinPath.isAbsolutePath())
|
if (!resolvedBinPath.isAbsolutePath())
|
||||||
@@ -180,11 +174,8 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (resolvedBinPath.isEmpty()) {
|
if (resolvedBinPath.isEmpty()) {
|
||||||
if (ok)
|
return make_unexpected(Tr::tr("The binary \"%1\" could not be located in the path \"%2\"")
|
||||||
*ok = false;
|
.arg(binaryPath().toUserOutput(), path()));
|
||||||
if (errorMessage)
|
|
||||||
*errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"")
|
|
||||||
.arg(binaryPath().toUserOutput(), path());
|
|
||||||
}
|
}
|
||||||
return resolvedBinPath;
|
return resolvedBinPath;
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ public:
|
|||||||
mutable Utils::FilePath resolvedBinPath;
|
mutable Utils::FilePath resolvedBinPath;
|
||||||
mutable bool tryResolve = true;
|
mutable bool tryResolve = true;
|
||||||
|
|
||||||
Utils::FilePath gitExecutable(bool *ok = nullptr, QString *errorMessage = nullptr) const;
|
Utils::expected_str<Utils::FilePath> gitExecutable() const;
|
||||||
|
|
||||||
static QString trIgnoreWhitespaceChanges();
|
static QString trIgnoreWhitespaceChanges();
|
||||||
static QString trIgnoreLineMoves();
|
static QString trIgnoreLineMoves();
|
||||||
|
Reference in New Issue
Block a user