diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-11 13:58:54 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-11 14:52:07 +0200 |
commit | 6d0d9197e3b25f528ff966081b6752a91c429e1a (patch) | |
tree | e22c22f16042ca392756b7d731db4614dcd70c05 /src/other_tools/utils | |
parent | 09a400e7a6ae4882ef770bf7eba3887050601ee8 (diff) | |
download | justbuild-6d0d9197e3b25f528ff966081b6752a91c429e1a.tar.gz |
Store HashInfo in just-mr's GitTreeInfo as tree_hash
...and use it to create ArtifactDigests.
Diffstat (limited to 'src/other_tools/utils')
-rw-r--r-- | src/other_tools/utils/TARGETS | 3 | ||||
-rw-r--r-- | src/other_tools/utils/parse_git_tree.cpp | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/other_tools/utils/TARGETS b/src/other_tools/utils/TARGETS index accde39f..6b4e00bd 100644 --- a/src/other_tools/utils/TARGETS +++ b/src/other_tools/utils/TARGETS @@ -76,7 +76,8 @@ , ["src/other_tools/ops_maps", "git_tree_fetch_map"] , ["src/utils/cpp", "expected"] ] - , "private-deps": [["@", "fmt", "", "fmt"]] + , "private-deps": + [["@", "fmt", "", "fmt"], ["src/buildtool/crypto", "hash_info"]] , "stage": ["src", "other_tools", "utils"] } } 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 <vector> #include "fmt/core.h" +#include "src/buildtool/crypto/hash_info.hpp" [[nodiscard]] auto ParseGitTree(ExpressionPtr const& repo_desc, std::optional<std::string> 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<std::string>{"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)}; |