diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/main/main.cpp | 12 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/TARGETS | 4 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/config.hpp | 16 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/serve_api.hpp | 17 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/source_tree_client.cpp | 32 | ||||
-rw-r--r-- | src/buildtool/serve_api/remote/source_tree_client.hpp | 20 | ||||
-rw-r--r-- | src/other_tools/just_mr/setup_utils.cpp | 12 | ||||
-rw-r--r-- | src/other_tools/root_maps/commit_git_map.cpp | 23 | ||||
-rw-r--r-- | src/other_tools/root_maps/content_git_map.cpp | 16 | ||||
-rw-r--r-- | src/other_tools/root_maps/distdir_git_map.cpp | 27 | ||||
-rw-r--r-- | src/other_tools/root_maps/foreign_file_git_map.cpp | 7 |
11 files changed, 87 insertions, 99 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index a9aea2eb..041046bf 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -170,21 +170,17 @@ void SetupExecutionConfig(EndpointArguments const& eargs, builder.SetBuildJobs(bargs.build_jobs); } - auto result = builder.Build(); - if (auto* config = std::get_if<RemoteServeConfig>(&result)) { + auto config = builder.Build(); + if (config) { if (config->tc_strategy == TargetCacheWriteStrategy::Disable) { Logger::Log( LogLevel::Info, "Target-level cache writing of serve service is disabled."); } - return std::move(*config); + return *std::move(config); } - if (auto* error = std::get_if<std::string>(&result)) { - Logger::Log(LogLevel::Error, *error); - return std::nullopt; - } - Logger::Log(LogLevel::Error, "Unknown error occured"); + Logger::Log(LogLevel::Error, config.error()); return std::nullopt; } diff --git a/src/buildtool/serve_api/remote/TARGETS b/src/buildtool/serve_api/remote/TARGETS index 4a92cd40..15aa6cd7 100644 --- a/src/buildtool/serve_api/remote/TARGETS +++ b/src/buildtool/serve_api/remote/TARGETS @@ -5,6 +5,7 @@ , "deps": [ ["src/buildtool/common/remote", "remote_common"] , ["src/buildtool/main", "build_utils"] + , ["src/utils/cpp", "expected"] , ["@", "fmt", "", "fmt"] ] , "stage": ["src", "buildtool", "serve_api", "remote"] @@ -16,6 +17,7 @@ , "srcs": ["source_tree_client.cpp"] , "deps": [ ["src/buildtool/common/remote", "port"] + , ["src/buildtool/file_system", "git_types"] , ["src/buildtool/file_system/symlinks_map", "pragma_special"] , ["src/buildtool/logging", "logging"] , ["src/buildtool/common/remote", "remote_common"] @@ -35,8 +37,10 @@ [ ["src/buildtool/common", "common"] , ["src/buildtool/common/remote", "port"] , ["src/buildtool/common/remote", "remote_common"] + , ["src/buildtool/file_system", "git_types"] , ["src/buildtool/file_system/symlinks_map", "pragma_special"] , ["src/buildtool/execution_api/common", "api_bundle"] + , ["src/utils/cpp", "expected"] , "source_tree_client" , "target_client" , "configuration_client" diff --git a/src/buildtool/serve_api/remote/config.hpp b/src/buildtool/serve_api/remote/config.hpp index 8c46a853..d19e7699 100644 --- a/src/buildtool/serve_api/remote/config.hpp +++ b/src/buildtool/serve_api/remote/config.hpp @@ -22,12 +22,12 @@ #include <optional> #include <string> #include <utility> -#include <variant> #include <vector> #include "fmt/core.h" #include "src/buildtool/common/remote/remote_common.hpp" #include "src/buildtool/main/build_utils.hpp" +#include "src/utils/cpp/expected.hpp" struct RemoteServeConfig final { class Builder; @@ -94,7 +94,7 @@ class RemoteServeConfig::Builder final { /// \brief Finalize building and create RemoteServeConfig. /// \return RemoteServeConfig on success or an error on failure. [[nodiscard]] auto Build() noexcept - -> std::variant<RemoteServeConfig, std::string> { + -> expected<RemoteServeConfig, std::string> { // To not duplicate default arguments of RemoteServeConfig in builder, // create a default config and copy default arguments from there. RemoteServeConfig const default_config; @@ -103,8 +103,9 @@ class RemoteServeConfig::Builder final { if (remote_address_.has_value()) { remote_address = ParseAddress(*remote_address_); if (not remote_address) { - return fmt::format("Setting serve service address '{}' failed.", - *remote_address_); + return unexpected{ + fmt::format("Setting serve service address '{}' failed.", + *remote_address_)}; } } @@ -117,7 +118,7 @@ class RemoteServeConfig::Builder final { if (jobs_.has_value()) { jobs = *jobs_; if (jobs == 0) { - return "Setting jobs failed."; + return unexpected{std::string{"Setting jobs failed."}}; } } @@ -125,7 +126,7 @@ class RemoteServeConfig::Builder final { if (build_jobs_.has_value()) { build_jobs = *build_jobs_; if (build_jobs == 0) { - return "Setting build jobs failed."; + return unexpected{std::string{"Setting build jobs failed."}}; } } @@ -134,7 +135,8 @@ class RemoteServeConfig::Builder final { action_timeout = *action_timeout_; if (bool const valid = action_timeout > std::chrono::seconds{0}; not valid) { - return "Setting action timeout failed."; + return unexpected{ + std::string{"Setting action timeout failed."}}; } } diff --git a/src/buildtool/serve_api/remote/serve_api.hpp b/src/buildtool/serve_api/remote/serve_api.hpp index 9175857b..7d265c92 100644 --- a/src/buildtool/serve_api/remote/serve_api.hpp +++ b/src/buildtool/serve_api/remote/serve_api.hpp @@ -23,18 +23,19 @@ class ServeApi final {}; #include <optional> #include <string> #include <unordered_map> -#include <variant> #include "src/buildtool/common/artifact.hpp" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/common/remote/port.hpp" #include "src/buildtool/common/remote/remote_common.hpp" #include "src/buildtool/execution_api/common/api_bundle.hpp" +#include "src/buildtool/file_system/git_types.hpp" #include "src/buildtool/file_system/symlinks_map/pragma_special.hpp" #include "src/buildtool/serve_api/remote/config.hpp" #include "src/buildtool/serve_api/remote/configuration_client.hpp" #include "src/buildtool/serve_api/remote/source_tree_client.hpp" #include "src/buildtool/serve_api/remote/target_client.hpp" +#include "src/utils/cpp/expected.hpp" class ServeApi final { public: @@ -62,7 +63,7 @@ class ServeApi final { [[nodiscard]] auto RetrieveTreeFromCommit(std::string const& commit, std::string const& subdir = ".", bool sync_tree = false) - const noexcept -> std::variant<bool, std::string> { + const noexcept -> expected<std::string, GitLookupError> { return stc_.ServeCommitTree(commit, subdir, sync_tree); } @@ -72,7 +73,7 @@ class ServeApi final { std::string const& subdir = ".", std::optional<PragmaSpecial> const& resolve_symlinks = std::nullopt, bool sync_tree = false) const noexcept - -> std::variant<bool, std::string> { + -> expected<std::string, GitLookupError> { return stc_.ServeArchiveTree( content, archive_type, subdir, resolve_symlinks, sync_tree); } @@ -81,14 +82,14 @@ class ServeApi final { std::shared_ptr<std::unordered_map<std::string, std::string>> const& distfiles, bool sync_tree = false) const noexcept - -> std::variant<bool, std::string> { + -> expected<std::string, GitLookupError> { return stc_.ServeDistdirTree(distfiles, sync_tree); } - [[nodiscard]] auto RetrieveTreeFromForeignFile( - const std::string& content, - const std::string& name, - bool executable) const noexcept -> std::variant<bool, std::string> { + [[nodiscard]] auto RetrieveTreeFromForeignFile(const std::string& content, + const std::string& name, + bool executable) + const noexcept -> expected<std::string, GitLookupError> { return stc_.ServeForeignFileTree(content, name, executable); } diff --git a/src/buildtool/serve_api/remote/source_tree_client.cpp b/src/buildtool/serve_api/remote/source_tree_client.cpp index 42ee21d8..82a7caf0 100644 --- a/src/buildtool/serve_api/remote/source_tree_client.cpp +++ b/src/buildtool/serve_api/remote/source_tree_client.cpp @@ -79,16 +79,18 @@ auto SourceTreeClient::ServeCommitTree(std::string const& commit_id, if (not status.ok()) { LogStatus(&logger_, LogLevel::Debug, status); - return true; // fatal failure + return unexpected{GitLookupError::Fatal}; } if (response.status() != ::justbuild::just_serve::ServeCommitTreeResponse::OK) { logger_.Emit(LogLevel::Debug, "ServeCommitTree response returned with {}", static_cast<int>(response.status())); - return /*fatal = */ ( + return unexpected{ response.status() != - ::justbuild::just_serve::ServeCommitTreeResponse::NOT_FOUND); + ::justbuild::just_serve::ServeCommitTreeResponse::NOT_FOUND + ? GitLookupError::Fatal + : GitLookupError::NotFound}; } return response.tree(); // success } @@ -113,16 +115,18 @@ auto SourceTreeClient::ServeArchiveTree( if (not status.ok()) { LogStatus(&logger_, LogLevel::Debug, status); - return true; // fatal failure + return unexpected{GitLookupError::Fatal}; } if (response.status() != ::justbuild::just_serve::ServeArchiveTreeResponse::OK) { logger_.Emit(LogLevel::Debug, "ServeArchiveTree response returned with {}", static_cast<int>(response.status())); - return /*fatal = */ ( + return unexpected{ response.status() != - ::justbuild::just_serve::ServeArchiveTreeResponse::NOT_FOUND); + ::justbuild::just_serve::ServeArchiveTreeResponse::NOT_FOUND + ? GitLookupError::Fatal + : GitLookupError::NotFound}; } return response.tree(); // success } @@ -146,16 +150,18 @@ auto SourceTreeClient::ServeDistdirTree( if (not status.ok()) { LogStatus(&logger_, LogLevel::Debug, status); - return true; // fatal failure + return unexpected{GitLookupError::Fatal}; } if (response.status() != ::justbuild::just_serve::ServeDistdirTreeResponse::OK) { logger_.Emit(LogLevel::Debug, "ServeDistdirTree response returned with {}", static_cast<int>(response.status())); - return /*fatal = */ ( + return unexpected{ response.status() != - ::justbuild::just_serve::ServeDistdirTreeResponse::NOT_FOUND); + ::justbuild::just_serve::ServeDistdirTreeResponse::NOT_FOUND + ? GitLookupError::Fatal + : GitLookupError::NotFound}; } return response.tree(); // success } @@ -176,7 +182,7 @@ auto SourceTreeClient::ServeForeignFileTree(const std::string& content, if (not status.ok()) { LogStatus(&logger_, LogLevel::Debug, status); - return true; // fatal failure + return unexpected{GitLookupError::Fatal}; } if (response.status() != ::justbuild::just_serve::ServeDistdirTreeResponse::OK) { @@ -184,9 +190,11 @@ auto SourceTreeClient::ServeForeignFileTree(const std::string& content, "ServeDistdirTree called for foreign file response " "returned with {}", static_cast<int>(response.status())); - return /*fatal = */ ( + return unexpected{ response.status() != - ::justbuild::just_serve::ServeDistdirTreeResponse::NOT_FOUND); + ::justbuild::just_serve::ServeDistdirTreeResponse::NOT_FOUND + ? GitLookupError::Fatal + : GitLookupError::NotFound}; } return response.tree(); // success } diff --git a/src/buildtool/serve_api/remote/source_tree_client.hpp b/src/buildtool/serve_api/remote/source_tree_client.hpp index 66d33005..802cb072 100644 --- a/src/buildtool/serve_api/remote/source_tree_client.hpp +++ b/src/buildtool/serve_api/remote/source_tree_client.hpp @@ -18,13 +18,14 @@ #include <memory> #include <string> #include <unordered_map> -#include <variant> #include "justbuild/just_serve/just_serve.grpc.pb.h" #include "src/buildtool/common/remote/port.hpp" #include "src/buildtool/common/remote/remote_common.hpp" +#include "src/buildtool/file_system/git_types.hpp" #include "src/buildtool/file_system/symlinks_map/pragma_special.hpp" #include "src/buildtool/logging/logger.hpp" +#include "src/utils/cpp/expected.hpp" /// Implements client side for SourceTree service defined in: /// src/buildtool/serve_api/serve_service/just_serve.proto @@ -33,7 +34,7 @@ class SourceTreeClient { explicit SourceTreeClient(ServerAddress const& address) noexcept; // An error + data union type - using result_t = std::variant<bool, std::string>; + using result_t = expected<std::string, GitLookupError>; /// \brief Retrieve the Git tree of a given commit, if known by the /// endpoint. It is a fatal error if the commit is known to the endpoint but @@ -41,9 +42,8 @@ class SourceTreeClient { /// \param[in] commit_id Hash of the Git commit to look up. /// \param[in] subdir Relative path of the tree inside commit. /// \param[in] sync_tree Sync tree to the remote-execution endpoint. - /// \returns An error + data union, where at index 0 we return a fatal flag, - /// with false meaning non-fatal failure (commit or subtree not found), and - /// at index 1 the tree identifier on success. + /// \returns The tree identifier on success or an unexpected error (fatal or + /// commit or subtree not found). [[nodiscard]] auto ServeCommitTree(std::string const& commit_id, std::string const& subdir, bool sync_tree) const noexcept @@ -58,9 +58,8 @@ class SourceTreeClient { /// \param[in] resolve_symlinks Optional enum to state how symlinks in the /// archive should be handled if the tree has to be actually computed. /// \param[in] sync_tree Sync tree to the remote-execution endpoint. - /// \returns An error + data union, where at index 0 we return a fatal flag, - /// with false meaning non-fatal failure (content blob not found), and at - /// index 1 the tree identifier on success. + /// \returns The tree identifier on success or an unexpected error (fatal or + /// content blob not found). [[nodiscard]] auto ServeArchiveTree( std::string const& content, std::string const& archive_type, @@ -74,9 +73,8 @@ class SourceTreeClient { /// \param[in] distfiles Mapping from distfile names to content blob ids. /// \param[in] sync_tree Sync tree and all ditfile blobs to the /// remote-execution endpoint. - /// \returns An error + data union, where at index 0 we return a fatal flag, - /// with false meaning non-fatal failure (at least one distfile blob - /// missing), and at index 1 the tree identifier on success. + /// \returns The tree identifier on success or an unexpected error (fatal or + /// at least one distfile blob missing). [[nodiscard]] auto ServeDistdirTree( std::shared_ptr<std::unordered_map<std::string, std::string>> const& distfiles, diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp index 4ed6f94d..1c55c9a3 100644 --- a/src/other_tools/just_mr/setup_utils.cpp +++ b/src/other_tools/just_mr/setup_utils.cpp @@ -259,19 +259,15 @@ auto CreateServeConfig(std::optional<std::string> const& remote_serve_addr, MultiRepoRemoteAuthArguments const& auth) noexcept -> std::optional<RemoteServeConfig> { RemoteServeConfig::Builder builder; - auto result = builder.SetRemoteAddress(remote_serve_addr).Build(); + auto config = builder.SetRemoteAddress(remote_serve_addr).Build(); - if (auto* config = std::get_if<RemoteServeConfig>(&result)) { + if (config) { // setup authentication SetupAuthConfig(auth); - return std::move(*config); + return *std::move(config); } - if (auto* error = std::get_if<std::string>(&result)) { - Logger::Log(LogLevel::Error, *error); - return std::nullopt; - } - Logger::Log(LogLevel::Error, "Unknown error occured"); + Logger::Log(LogLevel::Error, config.error()); return std::nullopt; } diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp index a8ef5eaf..18d80aa7 100644 --- a/src/other_tools/root_maps/commit_git_map.cpp +++ b/src/other_tools/root_maps/commit_git_map.cpp @@ -79,10 +79,9 @@ void EnsureRootAsAbsent(std::string const& tree_id, serve->RetrieveTreeFromCommit(repo_info.hash, repo_info.subdir, /*sync_tree = */ false); - if (std::holds_alternative<std::string>(serve_result)) { + if (serve_result) { // if serve has set up the tree, it must match what we expect - auto const& served_tree_id = - std::get<std::string>(serve_result); + auto const& served_tree_id = *serve_result; if (tree_id != served_tree_id) { (*logger)(fmt::format("Mismatch in served root tree " "id:\nexpected {}, but got {}", @@ -95,8 +94,7 @@ void EnsureRootAsAbsent(std::string const& tree_id, else { // check if serve failure was due to commit not being found or // it is otherwise fatal - auto const& is_fatal = std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == GitLookupError::Fatal) { (*logger)(fmt::format("Serve endpoint failed to set up " "root from known commit {}", repo_info.hash), @@ -515,7 +513,7 @@ void EnsureCommit(GitRepoInfo const& repo_info, serve->RetrieveTreeFromCommit(repo_info.hash, repo_info.subdir, /*sync_tree = */ false); - if (std::holds_alternative<std::string>(serve_result)) { + if (serve_result) { // set the workspace root as absent JustMRProgress::Instance().TaskTracker().Stop( repo_info.origin); @@ -524,14 +522,13 @@ void EnsureCommit(GitRepoInfo const& repo_info, {repo_info.ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker : FileRoot::kGitTreeMarker, - std::get<std::string>(serve_result)}), + *std::move(serve_result)}), /*is_cache_hit=*/false)); return; } // check if serve failure was due to commit not being found or // it is otherwise fatal - auto const& is_fatal = std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == GitLookupError::Fatal) { (*logger)(fmt::format("Serve endpoint failed to set up " "root from known commit {}", repo_info.hash), @@ -546,9 +543,8 @@ void EnsureCommit(GitRepoInfo const& repo_info, serve->RetrieveTreeFromCommit(repo_info.hash, /*subdir = */ ".", /*sync_tree = */ true); - if (std::holds_alternative<std::string>(serve_result)) { - auto const& root_tree_id = - std::get<std::string>(serve_result); + if (serve_result) { + auto const& root_tree_id = *serve_result; // verify if we know the tree already in the local Git cache GitOpKey op_key = { .params = @@ -845,8 +841,7 @@ void EnsureCommit(GitRepoInfo const& repo_info, // check if serve failure was due to commit not being found // or it is otherwise fatal - auto const& is_fatal = std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == GitLookupError::Fatal) { (*logger)(fmt::format("Serve endpoint failed to set up " "root from known commit {}", repo_info.hash), diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index eb4177d3..c55e0064 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -76,11 +76,10 @@ void EnsureRootAsAbsent(std::string const& tree_id, key.subdir, key.pragma_special, /*sync_tree=*/false); - if (std::holds_alternative<std::string>(serve_result)) { + if (serve_result) { // if serve has set up the tree, it must match what we // expect - auto const& served_tree_id = - std::get<std::string>(serve_result); + auto const& served_tree_id = *serve_result; if (tree_id != served_tree_id) { (*logger)(fmt::format("Mismatch in served root tree " "id:\nexpected {}, but got {}", @@ -93,8 +92,7 @@ void EnsureRootAsAbsent(std::string const& tree_id, else { // check if serve failure was due to archive content not // being found or it is otherwise fatal - auto const& is_fatal = std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == GitLookupError::Fatal) { (*logger)( fmt::format("Serve endpoint failed to set up " "root from known archive content {}", @@ -629,21 +627,19 @@ auto CreateContentGitMap( key.subdir, key.pragma_special, /*sync_tree = */ false); - if (std::holds_alternative<std::string>(serve_result)) { + if (serve_result) { // set the workspace root as absent JustMRProgress::Instance().TaskTracker().Stop( key.archive.origin); (*setter)(std::pair( nlohmann::json::array( - {FileRoot::kGitTreeMarker, - std::get<std::string>(serve_result)}), + {FileRoot::kGitTreeMarker, *serve_result}), /*is_cache_hit = */ false)); return; } // check if serve failure was due to archive content // not being found or it is otherwise fatal - auto const& is_fatal = std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == GitLookupError::Fatal) { (*logger)( fmt::format("Serve endpoint failed to set up root " "from known archive content {}", diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp index 46a2b9bf..5371b359 100644 --- a/src/other_tools/root_maps/distdir_git_map.cpp +++ b/src/other_tools/root_maps/distdir_git_map.cpp @@ -203,12 +203,10 @@ auto CreateDistdirGitMap( serve->RetrieveTreeFromDistdir( key.content_list, /*sync_tree=*/false); - if (std::holds_alternative<std::string>( - serve_result)) { + if (serve_result) { // if serve has set up the tree, it must // match what we expect - auto const& served_tree_id = - std::get<std::string>(serve_result); + auto const& served_tree_id = *serve_result; if (distdir_tree_id != served_tree_id) { (*logger)( fmt::format( @@ -224,9 +222,8 @@ auto CreateDistdirGitMap( // check if serve failure was due to distdir // content not being found or it is // otherwise fatal - auto const& is_fatal = - std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == + GitLookupError::Fatal) { (*logger)( fmt::format( "Serve endpoint failed to set " @@ -351,11 +348,10 @@ auto CreateDistdirGitMap( auto serve_result = serve->RetrieveTreeFromDistdir(key.content_list, /*sync_tree=*/false); - if (std::holds_alternative<std::string>(serve_result)) { + if (serve_result) { // if serve has set up the tree, it must match what we // expect - auto const& served_tree_id = - std::get<std::string>(serve_result); + auto const& served_tree_id = *serve_result; if (tree_id != served_tree_id) { (*logger)( fmt::format("Mismatch in served root tree " @@ -374,8 +370,7 @@ auto CreateDistdirGitMap( } // check if serve failure was due to distdir content not // being found or it is otherwise fatal - auto const& is_fatal = std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == GitLookupError::Fatal) { (*logger)( fmt::format("Serve endpoint failed to set up root " "from known distdir content {}", @@ -487,11 +482,10 @@ auto CreateDistdirGitMap( auto serve_result = serve->RetrieveTreeFromDistdir(key.content_list, /*sync_tree=*/true); - if (std::holds_alternative<std::string>(serve_result)) { + if (serve_result) { // if serve has set up the tree, it must match what we // expect - auto const& served_tree_id = - std::get<std::string>(serve_result); + auto const& served_tree_id = *serve_result; if (tree_id != served_tree_id) { (*logger)(fmt::format("Mismatch in served root tree " "id:\nexpected {}, but got {}", @@ -507,8 +501,7 @@ auto CreateDistdirGitMap( else { // check if serve failure was due to distdir content not // being found or it is otherwise fatal - auto const& is_fatal = std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == GitLookupError::Fatal) { (*logger)( fmt::format("Serve endpoint failed to set up root " "from known distdir content {}", diff --git a/src/other_tools/root_maps/foreign_file_git_map.cpp b/src/other_tools/root_maps/foreign_file_git_map.cpp index 809c34fc..1baa2af2 100644 --- a/src/other_tools/root_maps/foreign_file_git_map.cpp +++ b/src/other_tools/root_maps/foreign_file_git_map.cpp @@ -150,10 +150,10 @@ void HandleAbsentForeignFile(ForeignFileInfo const& key, } auto serve_result = serve->RetrieveTreeFromForeignFile( key.archive.content, key.name, key.executable); - if (std::holds_alternative<std::string>(serve_result)) { + if (serve_result) { // if serve has set up the tree, it must match what we // expect - auto const& served_tree_id = std::get<std::string>(serve_result); + auto const& served_tree_id = *serve_result; if (tree_id != served_tree_id) { (*logger)(fmt::format("Mismatch in served root tree " "id: expected {}, but got {}", @@ -168,8 +168,7 @@ void HandleAbsentForeignFile(ForeignFileInfo const& key, /*is_cache_hit=*/false)); return; } - auto const& is_fatal = std::get<bool>(serve_result); - if (is_fatal) { + if (serve_result.error() == GitLookupError::Fatal) { (*logger)(fmt::format("Serve endpoint failed to set up root " "from known foreign-file content {}", key.archive.content), |