Add resolvers.mli to define the public interface

Constrains the Resolvers module to only expose what handlers, views, and tests actually use. Removes dead code exposed by the restriction: - Reference.all (unused) - Reference.to_t (only used by all) - Blob.of_id (blob_or_tree reads directly from store)

Commit
5bd08b4ebd92cbd0c023239c18614349fd7df3e7
Author
Marius Peter <dev@marius-peter.com>
Author date
Committer
Marius Peter <dev@marius-peter.com>
Committer date
Changed files
lib/resolvers.ml
index 8baa0e9d..76391d12 100644..100644
@@ -185,19 +185,8 @@
185 185
186 186 let branch_name name = drop_prefix ~prefix:"refs/heads/" name
187 187 let tag_name name = drop_prefix ~prefix:"refs/tags/" name
188 Removed:
189 Removed: let to_t (reference, hash) =
190 Removed: { name = Git.Reference.to_string reference; hash = Store.Hash.to_hex hash }
191 Removed:
192 188 let to_t_with_name name (_, hash) = { name; hash = Store.Hash.to_hex hash }
193 189
194 Removed: let all repo =
195 Removed: let* store = store repo in
196 Removed: let open Lwt.Syntax in
197 Removed: let* references = Store.Ref.list store in
198 Removed: let references = List.map to_t references in
199 Removed: Lwt_result.return references
200 Removed:
201 190 let branches repo =
202 191 let* store = store repo in
203 192 let open Lwt.Syntax in
@@ -328,13 +317,6 @@
328 317 type t = { content : string }
329 318
330 319 let to_t blob = { content = Store.Value.Blob.to_string blob }
331 Removed:
332 Removed: let of_id repo id =
333 Removed: let* store = store repo in
334 Removed: let* hash = hash_of_hex id in
335 Removed: Lwt_result.bind (Store.read store hash) @@ function
336 Removed: | Git.Value.Blob blob -> Lwt_result.return (to_t blob)
337 Removed: | _ -> Lwt_result.fail @@ `Msg ("no blob matches id " ^ id)
338 320 end
339 321
340 322 module Diff = struct
lib/resolvers.mli
index 00000000..3cb008c6 000000..100644
@@ -0,0 +1,104 @@
1 Added: (* -*- mode: tuareg; -*- *)
2 Added:
3 Added: (** Git data access layer. *)
4 Added:
5 Added: module Store = Git_unix.Store
6 Added:
7 Added: (** {1 Validation} *)
8 Added:
9 Added: val is_valid_hash_hex : string -> bool
10 Added: val is_valid_repo_name : string -> bool
11 Added:
12 Added: (** {1 Repository discovery} *)
13 Added:
14 Added: type repository_layout = { worktree : string; git_dir : string }
15 Added:
16 Added: val is_repository : string -> bool
17 Added: val repository_layout : string -> repository_layout option
18 Added:
19 Added: (** {1 Repository metadata} *)
20 Added:
21 Added: val default_repo_description : string
22 Added: val read_description_file : string -> string
23 Added: val repo_description : string -> string
24 Added: val short_hash : string -> string
25 Added: val fallback_branch_candidates : unit -> string list
26 Added:
27 Added: (** {1 Commits} *)
28 Added:
29 Added: module Commit : sig
30 Added: type user = Git.User.t
31 Added:
32 Added: type t = {
33 Added: hash : string;
34 Added: tree : string;
35 Added: parents : string list;
36 Added: author : user;
37 Added: message : string option;
38 Added: }
39 Added:
40 Added: val of_id : string -> string -> (t, Store.error) Lwt_result.t
41 Added: val head : string -> (t, Store.error) Lwt_result.t
42 Added:
43 Added: val recent_from :
44 Added: string -> string -> int -> (t list, Store.error) Lwt_result.t
45 Added:
46 Added: val recent : string -> int -> (t list, Store.error) Lwt_result.t
47 Added: end
48 Added:
49 Added: (** {1 References} *)
50 Added:
51 Added: module Reference : sig
52 Added: type t = { name : string; hash : string }
53 Added:
54 Added: val branch_name : string -> string option
55 Added: val tag_name : string -> string option
56 Added: val branches : string -> (t list, Store.error) Lwt_result.t
57 Added: val tags : string -> (t list, Store.error) Lwt_result.t
58 Added: val of_id : string -> string -> (t, Store.error) Lwt_result.t
59 Added: end
60 Added:
61 Added: (** {1 Entries and Trees} *)
62 Added:
63 Added: module Entry : sig
64 Added: type perm = Dir | File | Exec | Link | Submodule
65 Added: type t = { hash : string; name : string; perm : perm }
66 Added:
67 Added: val is_readme : t -> bool
68 Added: end
69 Added:
70 Added: module Tree : sig
71 Added: type t = { entries : Entry.t list }
72 Added:
73 Added: val head : string -> (t, Store.error) Lwt_result.t
74 Added:
75 Added: val find_path :
76 Added: string -> string -> ((string * string) list, Store.error) Lwt_result.t
77 Added: end
78 Added:
79 Added: (** {1 Blobs} *)
80 Added:
81 Added: module Blob : sig
82 Added: type t = { content : string }
83 Added: end
84 Added:
85 Added: (** {1 Diffs} *)
86 Added:
87 Added: module Diff : sig
88 Added: include module type of Diff
89 Added:
90 Added: val of_commit : string -> Commit.t -> (file list, Store.error) Lwt_result.t
91 Added: end
92 Added:
93 Added: (** {1 Composite lookups} *)
94 Added:
95 Added: val blob_or_tree :
96 Added: string ->
97 Added: string ->
98 Added: ([> `Blob of Blob.t | `Tree of Tree.t ], Store.error) Lwt_result.t
99 Added:
100 Added: (** {1 Repository helpers} *)
101 Added:
102 Added: module Repo : sig
103 Added: val readme : string -> (Blob.t option, Store.error) Lwt_result.t
104 Added: end