summaryrefslogtreecommitdiff
path: root/src/other_tools/root_maps/commit_git_map.cpp
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2024-06-27 17:44:34 +0200
committerOliver Reiche <oliver.reiche@huawei.com>2024-06-28 11:34:53 +0200
commit01d9abcfc85d974763c3a7f8fed998342d92a681 (patch)
tree105a887360a49dfa8bf942f48c5560d29b0dcd6e /src/other_tools/root_maps/commit_git_map.cpp
parentf82ee35bff7363e6381d659b26773f260109e2ea (diff)
downloadjustbuild-01d9abcfc85d974763c3a7f8fed998342d92a681.tar.gz
Use (un)expected for serve API
Diffstat (limited to 'src/other_tools/root_maps/commit_git_map.cpp')
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp23
1 files changed, 9 insertions, 14 deletions
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),