summaryrefslogtreecommitdiff
path: root/lib/git_presenters.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git_presenters.ml')
-rw-r--r--lib/git_presenters.ml15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/git_presenters.ml b/lib/git_presenters.ml
index 215e9c5..e098ecc 100644
--- a/lib/git_presenters.ml
+++ b/lib/git_presenters.ml
@@ -2,8 +2,8 @@
module Store = Git_unix.Store
open Lwt_result.Syntax
-open Config
open Lwt_result.Infix
+open Config
let full_path path = Filename.concat config.git_project_root path
@@ -29,8 +29,7 @@ type commit = {
}
let to_commit store hash =
- let* v = Store.read store hash in
- match v with
+ Store.read store hash >>= function
| Git.Value.Commit c ->
let hash = Store.Hash.to_hex hash in
Lwt_result.return
@@ -102,14 +101,12 @@ let to_entry (entry : Store.Value.Tree.entry) =
let short_hash = String.sub hash 0 8 in
{ hash; short_hash; name = entry.name; perm }
-let present_tree tree = Store.Value.Tree.to_list tree |> List.map to_entry
-
let to_tree store hash =
Store.read store hash >>= function
| Git.Value.Tree tree ->
let hash = Store.Hash.to_hex hash in
let short_hash = String.sub hash 0 8 in
- let entries = present_tree tree in
+ let entries = Store.Value.Tree.to_list tree |> List.map to_entry in
Lwt_result.return { hash; short_hash; entries }
| _ -> Lwt_result.fail (`Msg "value is not a tree")
@@ -118,7 +115,7 @@ let to_blob store hash =
| Git.Value.Blob blob ->
let content = Store.Value.Blob.to_string blob in
Lwt_result.return { content }
- | _ -> Lwt_result.fail (`Msg "value is not a tree")
+ | _ -> Lwt_result.fail (`Msg "value is not a blob")
let head_tree_id store =
Store.Ref.resolve store Git.Reference.head >>= Store.read store >>= function
@@ -133,10 +130,10 @@ let head_tree repo =
let tree_of_id repo id =
let* store = store repo in
- let* hash = Lwt_result.return (Store.Hash.of_hex id) in
+ let hash = Store.Hash.of_hex id in
to_tree store hash
let blob_of_id repo id =
let* store = store repo in
- let* hash = Lwt_result.return (Store.Hash.of_hex id) in
+ let hash = Store.Hash.of_hex id in
to_blob store hash
Copyright 2019--2025 Marius PETER