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);
|
||||
GitBaseDiffEditorController *controller = factory(document);
|
||||
QTC_ASSERT(controller, return);
|
||||
controller->setVcsBinary(settings().gitExecutable());
|
||||
controller->setVcsBinary(settings().gitExecutable().value_or(FilePath{}));
|
||||
controller->setProcessEnvironment(processEnvironment());
|
||||
controller->setWorkingDirectory(workingDirectory);
|
||||
|
||||
@@ -2546,11 +2546,7 @@ bool GitClient::launchGitBash(const FilePath &workingDirectory)
|
||||
|
||||
FilePath GitClient::vcsBinary() const
|
||||
{
|
||||
bool ok;
|
||||
Utils::FilePath binary = settings().gitExecutable(&ok);
|
||||
if (!ok)
|
||||
return {};
|
||||
return binary;
|
||||
return settings().gitExecutable().value_or(FilePath{});
|
||||
}
|
||||
|
||||
// returns first line from log and removes it
|
||||
|
@@ -409,11 +409,9 @@ void GitPluginPrivate::onApplySettings()
|
||||
{
|
||||
emit configurationChanged();
|
||||
updateRepositoryBrowserAction();
|
||||
bool gitFoundOk;
|
||||
QString errorMessage;
|
||||
settings().gitExecutable(&gitFoundOk, &errorMessage);
|
||||
if (!gitFoundOk) {
|
||||
QTimer::singleShot(0, this, [errorMessage] {
|
||||
const expected_str<FilePath> result = settings().gitExecutable();
|
||||
if (!result) {
|
||||
QTimer::singleShot(0, this, [errorMessage = result.error()] {
|
||||
AsynchronousMessageBox::warning(Tr::tr("Git Settings"), errorMessage);
|
||||
});
|
||||
}
|
||||
|
@@ -164,14 +164,8 @@ GitSettings::GitSettings()
|
||||
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) {
|
||||
resolvedBinPath = binaryPath();
|
||||
if (!resolvedBinPath.isAbsolutePath())
|
||||
@@ -180,11 +174,8 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
|
||||
}
|
||||
|
||||
if (resolvedBinPath.isEmpty()) {
|
||||
if (ok)
|
||||
*ok = false;
|
||||
if (errorMessage)
|
||||
*errorMessage = Tr::tr("The binary \"%1\" could not be located in the path \"%2\"")
|
||||
.arg(binaryPath().toUserOutput(), path());
|
||||
return make_unexpected(Tr::tr("The binary \"%1\" could not be located in the path \"%2\"")
|
||||
.arg(binaryPath().toUserOutput(), path()));
|
||||
}
|
||||
return resolvedBinPath;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ public:
|
||||
mutable Utils::FilePath resolvedBinPath;
|
||||
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 trIgnoreLineMoves();
|
||||
|
Reference in New Issue
Block a user