summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2025-05-25 15:49:46 +0200
committerMarius Peter <marius.peter@tutanota.com>2025-05-25 15:49:46 +0200
commitd5d725630fb8eca2b8eb79a479044646f312b056 (patch)
tree942bfa1aa7f0916289a352a4430670b1c4cc9950
parent1f904a2eb07c5d98288aeb6d762f8f4668df79ca (diff)
Refactor helpers as presenters.
Rather than generically ``helping'', this module provides intermediate representations of ocaml-git objects usable by the Views module.
-rw-r--r--lib/git_presenters.ml (renamed from lib/git_helpers.ml)10
-rw-r--r--lib/handlers.ml6
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/git_helpers.ml b/lib/git_presenters.ml
index 1b32735..cdd9caa 100644
--- a/lib/git_helpers.ml
+++ b/lib/git_presenters.ml
@@ -12,13 +12,17 @@ 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
+module User = struct
+ type t = Git.User.t
+end
+
module Commit = struct
open Lwt_result.Syntax
type t = {
hash : string;
parents : string list;
- author : Git.User.t;
+ author : User.t;
message : string option;
}
@@ -70,7 +74,3 @@ module Branch = struct
in
Lwt_result.return branches
end
-
-module User = struct
- type t = Git.User.t
-end
diff --git a/lib/handlers.ml b/lib/handlers.ml
index a99f8ae..dadf0e1 100644
--- a/lib/handlers.ml
+++ b/lib/handlers.ml
@@ -12,8 +12,8 @@ module Repo = struct
let repo req = Dream.param req "repo_name"
let summary req =
- let* branches = Git_helpers.Branch.all_branches (repo req) in
- let* commits = Git_helpers.Commit.recent_commits (repo req) 10 in
+ let* branches = Git_presenters.Branch.all_branches (repo req) in
+ let* commits = Git_presenters.Commit.recent_commits (repo req) 10 in
let authors = [ "John Pork"; "Sebastian Jellybean" ] in
Views.Repo.summary (repo req) branches commits authors |> Dream_html.respond
@@ -23,7 +23,7 @@ module Repo = struct
let commit req =
let id = match Dream.query req "id" with Some id -> id | None -> "" in
- let* commit = Git_helpers.Commit.of_id (repo req) id in
+ let* commit = Git_presenters.Commit.of_id (repo req) id in
Views.Repo.commit (repo req) commit |> Dream_html.respond
end
Copyright 2019--2025 Marius PETER