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.ml16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/git_presenters.ml b/lib/git_presenters.ml
index cdd9caa..680a16c 100644
--- a/lib/git_presenters.ml
+++ b/lib/git_presenters.ml
@@ -1,13 +1,12 @@
module Store = Git_unix.Store
+open Config
-let full_path path = Filename.concat Config.git_directory path
+let full_path path = Filename.concat config.repositories_root path
let store repo =
let path = Fpath.v @@ full_path repo in
Store.v ~dotgit:path path
-let short_hash hash = String.sub hash 0 8
-
let repo_description repo =
let description_path = Filename.concat (full_path repo) "description" in
In_channel.with_open_text description_path In_channel.input_all
@@ -21,18 +20,21 @@ module Commit = struct
type t = {
hash : string;
+ short_hash : string;
parents : string list;
author : User.t;
message : string option;
}
- let of_hash store h =
+ let to_commit store h =
let* v = Store.read store h in
match v with
| Git.Value.Commit c ->
+ let hash = Store.Hash.to_hex h in
Lwt_result.return
{
- hash = Store.Hash.to_hex h;
+ hash;
+ short_hash = String.sub hash 0 8;
parents = Store.Value.Commit.parents c |> List.map Store.Hash.to_hex;
author = Store.Value.Commit.author c;
message = Store.Value.Commit.message c;
@@ -45,7 +47,7 @@ module Commit = struct
let rec walk acc hash count =
if count = 0 then Lwt_result.return (List.rev acc)
else
- let* commit = of_hash store hash in
+ let* commit = to_commit store hash in
match commit.parents with
| parent :: _ ->
walk (commit :: acc) (Store.Hash.of_hex parent) (count - 1)
@@ -57,7 +59,7 @@ module Commit = struct
let open Lwt_result.Syntax in
let* store = store repo in
let id = Store.Hash.of_hex id in
- of_hash store id
+ to_commit store id
end
module Branch = struct
Copyright 2019--2025 Marius PETER