summaryrefslogtreecommitdiff
path: root/src/other_tools/utils
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-11 12:19:15 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-11 14:52:07 +0200
commit09a400e7a6ae4882ef770bf7eba3887050601ee8 (patch)
tree2d54d6ff3985619d47ce8ae423853afc51f4ca3f /src/other_tools/utils
parentc34e0b72616c99a4704efc3950351c84487903ca (diff)
downloadjustbuild-09a400e7a6ae4882ef770bf7eba3887050601ee8.tar.gz
Store HashInfo in just-mr's ArchiveContent as content hash
...and use it to create ArtifactDigests.
Diffstat (limited to 'src/other_tools/utils')
-rw-r--r--src/other_tools/utils/TARGETS3
-rw-r--r--src/other_tools/utils/parse_archive.cpp15
2 files changed, 16 insertions, 2 deletions
diff --git a/src/other_tools/utils/TARGETS b/src/other_tools/utils/TARGETS
index 0987e6e5..accde39f 100644
--- a/src/other_tools/utils/TARGETS
+++ b/src/other_tools/utils/TARGETS
@@ -62,7 +62,8 @@
, ["src/other_tools/ops_maps", "content_cas_map"]
, ["src/utils/cpp", "expected"]
]
- , "private-deps": [["@", "fmt", "", "fmt"]]
+ , "private-deps":
+ [["@", "fmt", "", "fmt"], ["src/buildtool/crypto", "hash_info"]]
, "stage": ["src", "other_tools", "utils"]
}
, "parse_git_tree":
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 <utility> // 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<std::string>{"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,