summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/file_root.hpp
diff options
context:
space:
mode:
authorSascha Roloff <sascha.roloff@huawei.com>2022-07-08 11:49:31 +0200
committerSascha Roloff <sascha.roloff@huawei.com>2022-08-05 14:41:31 +0200
commit82ae2aa5a8cfb14a1547a608844bedee218d2c2d (patch)
tree380c17fb2984339d5c92533ef6136fc6a573c00f /src/buildtool/file_system/file_root.hpp
parentee56ad123c7d6eeec98c586df1976dfb6a624586 (diff)
downloadjustbuild-82ae2aa5a8cfb14a1547a608844bedee218d2c2d.tar.gz
Allow to read git trees from global CAS as well as local workspace root
Diffstat (limited to 'src/buildtool/file_system/file_root.hpp')
-rw-r--r--src/buildtool/file_system/file_root.hpp13
1 files changed, 13 insertions, 0 deletions
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(