forked from
gazagnaire.org/irmin
Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
1(** Log command. *)
2
3let run ~repo ~branch ~output ~limit () =
4 let config = Config.load ~repo () in
5 let (module B : Common.BACKEND) = Common.backend_of_config config in
6 Eio_main.run @@ fun env ->
7 let fs = Eio.Stdenv.cwd env in
8 Eio.Switch.run @@ fun sw ->
9 let store = B.open_store ~sw ~fs ~config in
10 let entries = B.log store ~branch ~limit in
11 match entries with
12 | [] ->
13 (match output with
14 | `Human -> Fmt.pr "No commits on %s@." branch
15 | `Json -> Fmt.pr "[]@.");
16 0
17 | _ ->
18 (match output with
19 | `Human ->
20 List.iter
21 (fun (e : Common.log_entry) ->
22 Fmt.pr "%a %s@. %s@.@." Common.styled_yellow
23 (String.sub e.hash 0 7) e.author e.message)
24 entries
25 | `Json ->
26 List.iter
27 (fun (e : Common.log_entry) ->
28 Fmt.pr {|{"hash":%S,"author":%S,"message":%S}@.|} e.hash e.author
29 e.message)
30 entries);
31 0