From 09a400e7a6ae4882ef770bf7eba3887050601ee8 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 11 Sep 2024 12:19:15 +0200 Subject: Store HashInfo in just-mr's ArchiveContent as content hash ...and use it to create ArtifactDigests. --- src/other_tools/utils/parse_archive.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/other_tools/utils/parse_archive.cpp') diff --git a/src/other_tools/utils/parse_archive.cpp b/src/other_tools/utils/parse_archive.cpp index a8fc1830..fb03309a 100644 --- a/src/other_tools/utils/parse_archive.cpp +++ b/src/other_tools/utils/parse_archive.cpp @@ -17,6 +17,7 @@ #include // std::move #include "fmt/core.h" +#include "src/buildtool/crypto/hash_info.hpp" auto ParseArchiveContent(ExpressionPtr const& repo_desc, std::string const& origin) @@ -32,6 +33,18 @@ auto ParseArchiveContent(ExpressionPtr const& repo_desc, fmt::format("Unsupported value {} for mandatory field \"content\"", repo_desc_content->get()->ToString())}; } + + auto const repo_desc_hash_info = + HashInfo::Create(HashFunction::Type::GitSHA1, + repo_desc_content->get()->String(), + /*is_tree=*/false); + if (not repo_desc_hash_info) { + return unexpected{fmt::format( + "Unsupported value {} for mandatory field \"content\"\n{}", + repo_desc_content->get()->ToString(), + repo_desc_hash_info.error())}; + } + auto repo_desc_fetch = repo_desc->At("fetch"); if (not repo_desc_fetch) { return unexpected{"Mandatory field \"fetch\" is missing"}; @@ -66,7 +79,7 @@ auto ParseArchiveContent(ExpressionPtr const& repo_desc, } return ArchiveContent{ - .content = repo_desc_content->get()->String(), + .content_hash = *repo_desc_hash_info, .distfile = repo_desc_distfile->IsString() ? std::make_optional(repo_desc_distfile->String()) : std::nullopt, -- cgit v1.2.3