diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-11-18 18:07:24 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-12-04 18:03:44 +0100 |
commit | d3ce7e1633ec8be6d76e43f7e28b4155c9f06b2a (patch) | |
tree | 3a8826edb3f5dcb533833e9a7d8d4abedcf55459 /src/buildtool/execution_api/utils/rehash_utils.cpp | |
parent | 8d13fd367ab92663afa2777182cefaaa135fe749 (diff) | |
download | justbuild-d3ce7e1633ec8be6d76e43f7e28b4155c9f06b2a.tar.gz |
Add RehashGitDigest function
Diffstat (limited to 'src/buildtool/execution_api/utils/rehash_utils.cpp')
-rw-r--r-- | src/buildtool/execution_api/utils/rehash_utils.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/src/buildtool/execution_api/utils/rehash_utils.cpp b/src/buildtool/execution_api/utils/rehash_utils.cpp index bbaefaeb..c5ca60c2 100644 --- a/src/buildtool/execution_api/utils/rehash_utils.cpp +++ b/src/buildtool/execution_api/utils/rehash_utils.cpp @@ -136,11 +136,11 @@ template <std::invocable<ArtifactDigest const&, ObjectType> TReadCallback> [&target_storage]( std::variant<std::filesystem::path, std::string> const& data, bool is_exec) -> std::optional<ArtifactDigest> { - if (not std::holds_alternative<std::filesystem::path>(data)) { - return std::nullopt; - } - return target_storage.CAS().StoreBlob( - std::get<std::filesystem::path>(data), is_exec); + return std::visit( + [&target_storage, is_exec](auto const& d) { + return target_storage.CAS().StoreBlob(d, is_exec); + }, + data); }; BazelMsgFactory::TreeStoreFunc store_dir = [&cas = target_storage.CAS()](std::string const& content) { @@ -252,4 +252,21 @@ auto RehashDigest(std::vector<Artifact::ObjectInfo> const& digests, /*from_git=*/false); } +auto RehashGitDigest(std::vector<Artifact::ObjectInfo> const& digests, + StorageConfig const& source_config, + StorageConfig const& target_config, + RepositoryConfig const& repo_config) + -> expected<std::vector<Artifact::ObjectInfo>, std::string> { + auto read = [&repo_config]( + ArtifactDigest const& digest, + ObjectType /*type*/) -> std::optional<std::string> { + return repo_config.ReadBlobFromGitCAS(digest.hash()); + }; + return RehashDigestImpl(digests, + source_config, + target_config, + std::move(read), + /*from_git=*/true); +} + } // namespace RehashUtils |