diff options
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. |