From 82ae2aa5a8cfb14a1547a608844bedee218d2c2d Mon Sep 17 00:00:00 2001 From: Sascha Roloff Date: Fri, 8 Jul 2022 11:49:31 +0200 Subject: Allow to read git trees from global CAS as well as local workspace root --- src/buildtool/file_system/file_root.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/buildtool/file_system/file_root.hpp') diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp index 10b04c66..893b028c 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -421,6 +421,19 @@ class FileRoot { return std::nullopt; } + [[nodiscard]] auto ReadTree(std::string const& tree_id) const noexcept + -> std::optional { + if (std::holds_alternative(root_)) { + try { + auto const& cas = std::get(root_).cas; + return GitTree::Read(cas, tree_id); + } catch (...) { + return std::nullopt; + } + } + return std::nullopt; + } + // Create LOCAL or KNOWN artifact. Does not check existence for LOCAL. // `file_path` must reference a blob. [[nodiscard]] auto ToArtifactDescription( -- cgit v1.2.3