diff options
| author | Marius Peter <marius.peter@tutanota.com> | 2025-06-29 01:10:52 +0200 | 
|---|---|---|
| committer | Marius Peter <marius.peter@tutanota.com> | 2025-06-29 01:10:52 +0200 | 
| commit | 9d587fb683218ca4346e3745520649e214e6d02b (patch) | |
| tree | a7a930279bc818d2960df1197cf1b4a78d418ff0 /lib | |
| parent | 331f1d2baa0bafa32d8bfc3d947ae3af7fc12796 (diff) | |
Refactor resolvers.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/resolvers.ml | 14 | 
1 files changed, 8 insertions, 6 deletions
| diff --git a/lib/resolvers.ml b/lib/resolvers.ml index 0db0e10..d6c62a8 100644 --- a/lib/resolvers.ml +++ b/lib/resolvers.ml @@ -89,6 +89,8 @@ module Entry = struct    type t = { hash : string; name : string; perm : int }    let to_t (entry : Store.Value.Tree.entry) = +    let hash = Store.Hash.to_hex entry.node in +    let name = entry.name in      let perm =        match entry.perm with        | `Commit -> 0o160000 @@ -98,17 +100,17 @@ module Entry = struct        | `Link -> 0o120000        | `Normal -> 0o100644      in -    let hash = Store.Hash.to_hex entry.node in -    { hash; name = entry.name; perm } +    { hash; name; perm }  end  module Tree = struct -  type t = { hash : string; entries : Entry.t list } +  type t = { hash : string; path : string; entries : Entry.t list }    let to_t tree =      let hash = Store.Value.Tree.hash tree |> Int.to_string in +    let path = "/" in      let entries = Store.Value.Tree.to_list tree |> List.map Entry.to_t in -    { hash; entries } +    { hash; path; entries }    let of_id repo id =      let* store = store repo in @@ -119,8 +121,8 @@ module Tree = struct    let head repo =      let* store = store repo in -    let* commit_hash = Store.Ref.resolve store Git.Reference.head in -    Lwt_result.bind (Store.read store commit_hash) @@ function +    let* hash = Store.Ref.resolve store Git.Reference.head in +    Lwt_result.bind (Store.read store hash) @@ function      | Git.Value.Commit commit ->          let tree_id = Store.Value.Commit.tree commit |> Store.Hash.to_hex in          of_id repo tree_id | 
