diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-21 15:43:59 +0100 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2025-01-23 16:50:37 +0100 |
commit | 19ddb7b9ef8bb862ed70528d3bc831eae1c59377 (patch) | |
tree | 8be3d0c8789e785e228752c60ff57391bc1b9568 /src/other_tools/root_maps | |
parent | 98f9a38d858a1674cfc10b689b360ca4498ce72a (diff) | |
download | justbuild-19ddb7b9ef8bb862ed70528d3bc831eae1c59377.tar.gz |
JustMr: CommitGitMap: Use serve calls
...instead of EnsureAbsentRootOnServe.
Diffstat (limited to 'src/other_tools/root_maps')
-rw-r--r-- | src/other_tools/root_maps/TARGETS | 2 | ||||
-rw-r--r-- | src/other_tools/root_maps/commit_git_map.cpp | 39 |
2 files changed, 21 insertions, 20 deletions
diff --git a/src/other_tools/root_maps/TARGETS b/src/other_tools/root_maps/TARGETS index 8e6e40a8..dbd9c359 100644 --- a/src/other_tools/root_maps/TARGETS +++ b/src/other_tools/root_maps/TARGETS @@ -59,7 +59,9 @@ , "private-deps": [ "root_utils" , ["@", "fmt", "", "fmt"] + , ["src/buildtool/common", "artifact_digest_factory"] , ["src/buildtool/common", "common"] + , ["src/buildtool/crypto", "hash_function"] , ["src/buildtool/file_system", "file_root"] , ["src/buildtool/file_system", "file_system_manager"] , ["src/buildtool/file_system", "git_cas"] diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp index 942bd00f..0b9fe0dd 100644 --- a/src/other_tools/root_maps/commit_git_map.cpp +++ b/src/other_tools/root_maps/commit_git_map.cpp @@ -22,6 +22,8 @@ #include "fmt/core.h" #include "src/buildtool/common/artifact.hpp" #include "src/buildtool/common/artifact_digest.hpp" +#include "src/buildtool/common/artifact_digest_factory.hpp" +#include "src/buildtool/crypto/hash_function.hpp" #include "src/buildtool/file_system/file_root.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/file_system/git_cas.hpp" @@ -73,10 +75,10 @@ void EnsureRootAsAbsent( std::filesystem::path const& repo_root, GitRepoInfo const& repo_info, ServeApi const* serve, - gsl::not_null<StorageConfig const*> const& native_storage_config, - StorageConfig const* compat_storage_config, - gsl::not_null<IExecutionApi const*> const& local_api, - IExecutionApi const* remote_api, + gsl::not_null<StorageConfig const*> const& /*native_storage_config*/, + StorageConfig const* /*compat_storage_config*/, + gsl::not_null<IExecutionApi const*> const& /*local_api*/, + IExecutionApi const* /*remote_api*/, CommitGitMap::SetterPtr const& ws_setter, CommitGitMap::LoggerPtr const& logger) { // this is an absent root @@ -115,26 +117,23 @@ void EnsureRootAsAbsent( /*fatal=*/true); return; } - if (remote_api == nullptr) { - (*logger)( - fmt::format("Missing or incompatible remote-execution " - "endpoint needed to sync workspace root {} " - "with the serve endpoint.", - tree_id), - /*fatal=*/true); + + auto digest = + ArtifactDigestFactory::Create(HashFunction::Type::GitSHA1, + tree_id, + /*size_unknown=*/0, + /*is_tree=*/true); + if (not digest.has_value()) { + (*logger)(std::move(digest).error(), /*fatal=*/true); return; } + // the tree is known locally, so we can upload it to remote CAS // for the serve endpoint to retrieve it and set up the root - if (not EnsureAbsentRootOnServe(*serve, - tree_id, - repo_root, - native_storage_config, - compat_storage_config, - &*local_api, - remote_api, - logger, - true /*no_sync_is_fatal*/)) { + auto uploaded = serve->UploadTree(*digest, repo_root); + if (not uploaded.has_value()) { + (*logger)(std::move(uploaded).error().Message(), + /*fatal=*/true); return; } } |