diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/common/repository_config.hpp | 5 | ||||
-rw-r--r-- | src/buildtool/file_system/file_root.hpp | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/buildtool/common/repository_config.hpp b/src/buildtool/common/repository_config.hpp index e1144789..e6237e3f 100644 --- a/src/buildtool/common/repository_config.hpp +++ b/src/buildtool/common/repository_config.hpp @@ -61,6 +61,11 @@ class RepositoryConfig { : std::nullopt; } + [[nodiscard]] auto ReadTreeFromGitCAS( + std::string const& hex_id) const noexcept -> std::optional<GitTree> { + return git_cas_ ? GitTree::Read(git_cas_, hex_id) : std::nullopt; + } + [[nodiscard]] auto WorkspaceRoot(std::string const& repo) const noexcept -> FileRoot const* { return Get<FileRoot>( 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<GitTree> { + if (std::holds_alternative<git_root_t>(root_)) { + try { + auto const& cas = std::get<git_root_t>(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( |