[OCaml] Mobile-friendly clone of cgit.
Deduplicate Commit.recent by delegating to recent_from
recent now resolves HEAD and calls recent_from, eliminating the duplicated walk logic.
lib/resolvers.ml
@@ -157,18 +157,6 @@
157
157
let id = hash |> Store.Hash.to_hex in
158
158
of_id repo id
159
159
160
Removed:
let recent repo n =
161
Removed:
let* head_commit = head repo in
162
Removed:
let rec walk acc hash count =
163
Removed:
if count = 0 then Lwt_result.return (List.rev acc)
164
Removed:
else
165
Removed:
let* commit = of_id repo hash in
166
Removed:
match commit.parents with
167
Removed:
| parent_hash :: _ -> walk (commit :: acc) parent_hash (count - 1)
168
Removed:
| [] -> Lwt_result.return (List.rev (commit :: acc))
169
Removed:
in
170
Removed:
walk [] head_commit.hash n
171
Removed:
172
160
let recent_from repo hash n =
173
161
let rec walk acc hash count =
174
162
if count = 0 then Lwt_result.return (List.rev acc)
@@ -179,6 +167,10 @@
179
167
| [] -> Lwt_result.return (List.rev (commit :: acc))
180
168
in
181
169
walk [] hash n
170
Added:
171
Added:
let recent repo n =
172
Added:
let* head_commit = head repo in
173
Added:
recent_from repo head_commit.hash n
182
174
end
183
175
184
176
module Reference = struct