From e58a89c4f4803b7db69f2e830e51569b3e27c676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 18 Dec 2024 15:35:28 +0100 Subject: [PATCH 1/2] app/mgit: Initialize the RNG --- app/dune | 2 +- app/mgit.ml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/dune b/app/dune index db9e16b..6c5e5c0 100644 --- a/app/dune +++ b/app/dune @@ -1,3 +1,3 @@ (executable (name mgit) - (libraries mirage-clock-unix logs.fmt fmt.tty git-unix git-kv)) + (libraries mirage-clock-unix logs.fmt fmt.tty git-unix git-kv mirage-crypto-rng.unix)) diff --git a/app/mgit.ml b/app/mgit.ml index e9e065f..22c4595 100644 --- a/app/mgit.ml +++ b/app/mgit.ml @@ -169,6 +169,10 @@ let run remote = function | Ok t -> repl t Unix.stdin | Error (`Msg err) -> Fmt.failwith "%s." err ) +let run remote filename_opt = + let () = Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna) in + run remote filename_opt + let () = match Sys.argv with | [| _; remote; |] -> run remote None | [| _; remote; filename; |] when Sys.file_exists filename -> -- 2.47.1 From 64653f79d57f46960039c27fd10d9c2928edf1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 18 Dec 2024 15:35:43 +0100 Subject: [PATCH 2/2] app/mgit: Add mtime command to list last_modified --- app/mgit.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/mgit.ml b/app/mgit.ml index 22c4595..067e62f 100644 --- a/app/mgit.ml +++ b/app/mgit.ml @@ -82,6 +82,15 @@ let list ~quiet store key = if not quiet then Fmt.epr "%a.\n%!" Store.pp_error err ; Lwt.return (Ok 1) +let last_modified ~quiet store key = + Store.last_modified store key >>= function + | Ok time -> + Fmt.pr "%a\n%!" Ptime.pp time; + Lwt.return (Ok 0) + | Error err -> + if not quiet then Fmt.epr "%a.\n%!" Store.pp_error err ; + Lwt.return (Ok 1) + let pull ~quiet store = Git_kv.pull store >>= function | Error (`Msg err) -> if not quiet then Fmt.epr "%s.\n%!" err ; Lwt.return (Ok 1) @@ -134,6 +143,9 @@ let repl store fd_in = | [ "list"; key; ] -> with_key ~f:(list ~quiet:false store0) key >|= ignore >>= fun () -> go store0 + | [ "mtime"; key; ] -> + with_key ~f:(last_modified ~quiet:false store0) key + >|= ignore >>= fun () -> go store0 | [ "pull"; ] -> if is_a_tty then Fmt.pr "\n%!" ; pull ~quiet:false store0 >|= ignore >>= fun () -> go store0 -- 2.47.1