From 6d0d9197e3b25f528ff966081b6752a91c429e1a Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 11 Sep 2024 13:58:54 +0200 Subject: Store HashInfo in just-mr's GitTreeInfo as tree_hash ...and use it to create ArtifactDigests. --- src/other_tools/utils/parse_git_tree.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/other_tools/utils/parse_git_tree.cpp') diff --git a/src/other_tools/utils/parse_git_tree.cpp b/src/other_tools/utils/parse_git_tree.cpp index dde759b9..0e58676d 100644 --- a/src/other_tools/utils/parse_git_tree.cpp +++ b/src/other_tools/utils/parse_git_tree.cpp @@ -19,6 +19,7 @@ #include #include "fmt/core.h" +#include "src/buildtool/crypto/hash_info.hpp" [[nodiscard]] auto ParseGitTree(ExpressionPtr const& repo_desc, std::optional origin) @@ -34,6 +35,17 @@ repo_desc_hash->get()->ToString())}; } + auto repo_desc_hash_info = HashInfo::Create(HashFunction::Type::GitSHA1, + repo_desc_hash->get()->String(), + /*is_tree=*/true); + if (not repo_desc_hash_info) { + return unexpected{ + fmt::format("Unsupported value {} for " + "mandatory field \"id\"\n{}", + repo_desc_hash->get()->ToString(), + std::move(repo_desc_hash_info).error())}; + } + auto repo_desc_cmd = repo_desc->At("cmd"); if (not repo_desc_cmd) { return unexpected{"Mandatory field \"cmd\" is missing"}; @@ -90,7 +102,7 @@ } } // populate struct - auto info = GitTreeInfo{.hash = repo_desc_hash->get()->String(), + auto info = GitTreeInfo{.tree_hash = *std::move(repo_desc_hash_info), .env_vars = std::move(env), .inherit_env = std::move(inherit_env), .command = std::move(cmd)}; -- cgit v1.2.3