summaryrefslogtreecommitdiff
path: root/lib/resolvers.ml
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-06-29 01:09:09 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-06-29 01:09:09 +0200
commit331f1d2baa0bafa32d8bfc3d947ae3af7fc12796 (patch)
treeae94c09f870fab78c64f9e3e657feae3567bd5b2 /lib/resolvers.ml
parentb56bdde770615fb5c59f34d3f5c58d70ca9ad73b (diff)
Differentiate (sub-)tree and blob views.
Diffstat (limited to 'lib/resolvers.ml')
-rw-r--r--lib/resolvers.ml9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/resolvers.ml b/lib/resolvers.ml
index 741c797..0db0e10 100644
--- a/lib/resolvers.ml
+++ b/lib/resolvers.ml
@@ -139,3 +139,12 @@ module Blob = struct
| Git.Value.Blob blob -> Lwt_result.return (to_t blob)
| _ -> Lwt_result.fail @@ `Msg ("no blob matches id " ^ id)
end
+
+let blob_or_tree repo id =
+ let* store = store repo in
+ let hash = Store.Hash.of_hex id in
+ let* obj = Store.read store hash in
+ match obj with
+ | Git.Value.Tree tree -> Lwt_result.return @@ `Tree (Tree.to_t tree)
+ | Git.Value.Blob blob -> Lwt_result.return @@ `Blob (Blob.to_t blob)
+ | _ -> Lwt_result.fail @@ `Msg ("No tree or blob matches id " ^ id)
Copyright 2019--2025 Marius PETER