diff options
author | Oliver Reiche <oliver.reiche@huawei.com> | 2022-07-12 18:39:08 +0200 |
---|---|---|
committer | Sascha Roloff <sascha.roloff@huawei.com> | 2022-08-05 14:41:31 +0200 |
commit | e9037a921755b385b274ae6b05b79c49958affdc (patch) | |
tree | 75da7084f023e87566558e4c5529fa8d93e2300b /src | |
parent | d9bcc5b103f6e5415e779a2784e2d23f98705c39 (diff) | |
download | justbuild-e9037a921755b385b274ae6b05b79c49958affdc.tar.gz |
BazelMsgFactory: Implement reading object infos from Git tree
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp | 26 | ||||
-rw-r--r-- | src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp | 6 |
2 files changed, 32 insertions, 0 deletions
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp index 7cd9af69..ead45f6e 100644 --- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp +++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp @@ -457,6 +457,32 @@ auto BazelMsgFactory::ReadObjectInfosFromDirectory( return true; } +auto BazelMsgFactory::ReadObjectInfosFromGitTree( + GitCAS::tree_entries_t const& entries, + InfoStoreFunc const& store_info) noexcept -> bool { + try { + for (auto const& [raw_id, es] : entries) { + auto const hex_id = ToHexString(raw_id); + for (auto const& entry : es) { + if (not store_info(entry.name, + Artifact::ObjectInfo{ + ArtifactDigest{hex_id, + /*size is unknown*/ 0, + IsTreeObject(entry.type)}, + entry.type})) { + return false; + } + } + } + } catch (std::exception const& ex) { + Logger::Log(LogLevel::Error, + "reading object infos from Git tree failed with:\n{}", + ex.what()); + return false; + } + return true; +} + auto BazelMsgFactory::CreateDirectoryDigestFromTree( std::vector<DependencyGraph::NamedArtifactNodePtr> const& artifacts, std::optional<BlobStoreFunc> const& store_blob, diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp index 8675cc92..5044a646 100644 --- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp +++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp @@ -40,6 +40,12 @@ class BazelMsgFactory { bazel_re::Directory const& dir, InfoStoreFunc const& store_info) noexcept -> bool; + /// \brief Read object infos from git tree. + /// \returns true on success. + [[nodiscard]] static auto ReadObjectInfosFromGitTree( + GitCAS::tree_entries_t const& entries, + InfoStoreFunc const& store_info) noexcept -> bool; + /// \brief Create Directory digest from artifact tree structure. /// Recursively traverse entire tree and create blobs for sub-directories. /// \param artifacts Artifact tree structure. |