From 0000839adc5805997d5afdda924fb6f5e45e0a90 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 18 Dec 2024 12:46:40 +0100 Subject: FileRoot: disclose RootGit data. --- src/buildtool/file_system/file_root.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/buildtool/file_system/file_root.hpp b/src/buildtool/file_system/file_root.hpp index cabd2aae..68ca7533 100644 --- a/src/buildtool/file_system/file_root.hpp +++ b/src/buildtool/file_system/file_root.hpp @@ -393,6 +393,25 @@ class FileRoot { return std::nullopt; } + [[nodiscard]] auto GetTreeHash() const noexcept + -> std::optional { + if (auto const* root_git = std::get_if(&root_)) { + return root_git->tree->FileRootHash(); + } + if (auto const* absent_root = std::get_if(&root_)) { + return *absent_root; + } + return std::nullopt; + } + + [[nodiscard]] auto GetGitCasRoot() const noexcept + -> std::optional { + if (auto const* git_root = std::get_if(&root_)) { + return git_root->cas->GetPath(); + } + return std::nullopt; + } + // Indicates that subsequent calls to `Exists()`, `IsFile()`, // `IsDirectory()`, and `BlobType()` on contents of the same directory will // be served without any additional file system lookups. -- cgit v1.2.3