summaryrefslogtreecommitdiff
path: root/lib/resolvers.ml
diff options
context:
space:
mode:
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