summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp23
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp5
2 files changed, 28 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 ead45f6e..8d4d06c7 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
@@ -680,3 +680,26 @@ auto BazelMsgFactory::DirectoryToString(bazel_re::Directory const& dir) noexcept
return std::nullopt;
}
}
+
+auto BazelMsgFactory::GitTreeToString(
+ GitCAS::tree_entries_t const& entries) noexcept
+ -> std::optional<std::string> {
+ auto json = nlohmann::json::object();
+ try {
+ if (not BazelMsgFactory::ReadObjectInfosFromGitTree(
+ entries, [&json](auto path, auto info) {
+ json[path.string()] = info.ToString(/*size_unknown=*/true);
+ return true;
+ })) {
+ Logger::Log(LogLevel::Error,
+ "reading object infos from Directory failed");
+ return std::nullopt;
+ }
+ return json.dump(2) + "\n";
+ } catch (std::exception const& ex) {
+ Logger::Log(LogLevel::Error,
+ "dumping Directory to string failed with:\n{}",
+ ex.what());
+ return std::nullopt;
+ }
+}
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 5044a646..06d981eb 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.hpp
@@ -113,6 +113,11 @@ class BazelMsgFactory {
[[nodiscard]] static auto DirectoryToString(
bazel_re::Directory const& dir) noexcept -> std::optional<std::string>;
+ /// \brief Create descriptive string from Git tree entries.
+ [[nodiscard]] static auto GitTreeToString(
+ GitCAS::tree_entries_t const& entries) noexcept
+ -> std::optional<std::string>;
+
/// \brief Create message vector from std::map.
/// \param[in] input map
/// \tparam T protobuf message type. It must be a name-value