[OCaml] Mobile-friendly clone of cgit.
Refactor resolvers.
lib/resolvers.ml
@@ -89,6 +89,8 @@
89
89
type t = { hash : string; name : string; perm : int }
90
90
91
91
let to_t (entry : Store.Value.Tree.entry) =
92
Added:
let hash = Store.Hash.to_hex entry.node in
93
Added:
let name = entry.name in
92
94
let perm =
93
95
match entry.perm with
94
96
| `Commit -> 0o160000
@@ -98,17 +100,17 @@
98
100
| `Link -> 0o120000
99
101
| `Normal -> 0o100644
100
102
in
101
Removed:
let hash = Store.Hash.to_hex entry.node in
102
Removed:
{ hash; name = entry.name; perm }
103
Added:
{ hash; name; perm }
103
104
end
104
105
105
106
module Tree = struct
106
Removed:
type t = { hash : string; entries : Entry.t list }
107
Added:
type t = { hash : string; path : string; entries : Entry.t list }
107
108
108
109
let to_t tree =
109
110
let hash = Store.Value.Tree.hash tree |> Int.to_string in
111
Added:
let path = "/" in
110
112
let entries = Store.Value.Tree.to_list tree |> List.map Entry.to_t in
111
Removed:
{ hash; entries }
113
Added:
{ hash; path; entries }
112
114
113
115
let of_id repo id =
114
116
let* store = store repo in
@@ -119,8 +121,8 @@
119
121
120
122
let head repo =
121
123
let* store = store repo in
122
Removed:
let* commit_hash = Store.Ref.resolve store Git.Reference.head in
123
Removed:
Lwt_result.bind (Store.read store commit_hash) @@ function
124
Added:
let* hash = Store.Ref.resolve store Git.Reference.head in
125
Added:
Lwt_result.bind (Store.read store hash) @@ function
124
126
| Git.Value.Commit commit ->
125
127
let tree_id = Store.Value.Commit.tree commit |> Store.Hash.to_hex in
126
128
of_id repo tree_id