From 3f8544c8046acc9d6c0453f06d766cabae9cd88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Tue, 14 Jan 2025 11:23:22 +0100 Subject: [PATCH] Update to git-kv.0.1.2 and workaround git-kv bug Git-kv 0.1.1 has a bug in its last_modified implementation, and the current semantics has an odd interaction with change_and_push that we need to work around. --- dune-project | 2 +- plugins/yocaml_git/yocaml_git.ml | 13 +++++++++++++ yocaml_git.opam | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dune-project b/dune-project index e6f6ab9..3947500 100644 --- a/dune-project +++ b/dune-project @@ -152,7 +152,7 @@ (lwt (>= 5.7.0)) (mimic (>= 0.0.9)) (cstruct (>= 6.2.0)) - (git-kv (>= 0.0.5)) + (git-kv (>= 0.1.2)) (git-unix (>= 3.16.1)) (mirage-clock (>= 4.2.0)) (yocaml (= :version)) diff --git a/plugins/yocaml_git/yocaml_git.ml b/plugins/yocaml_git/yocaml_git.ml index 99125ac..d05643f 100644 --- a/plugins/yocaml_git/yocaml_git.ml +++ b/plugins/yocaml_git/yocaml_git.ml @@ -26,6 +26,19 @@ let run (module Source : Required.SOURCE) (module Clock : Mirage_clock.PCLOCK) let* context = match context with `SSH -> Ssh.context () in let* store = Git_kv.connect context remote in let module Store = Git_kv.Make (Clock) in + let module Store = struct + include Store + (* last_modified and change_and_push have a weird interaction; + so we show the old last_modified *) + let last_modified new_store key = + let* r = last_modified store key in + match r with + | Error `Not_found _ -> + last_modified new_store key + | _ -> + Lwt.return r + end + in Store.change_and_push ?author ?author_email:email ?message store (fun store -> let module Config = struct let store = store diff --git a/yocaml_git.opam b/yocaml_git.opam index 46c7d73..c8d875e 100644 --- a/yocaml_git.opam +++ b/yocaml_git.opam @@ -16,7 +16,7 @@ depends: [ "lwt" {>= "5.7.0"} "mimic" {>= "0.0.9"} "cstruct" {>= "6.2.0"} - "git-kv" {>= "0.0.5"} + "git-kv" {>= "0.1.2"} "git-unix" {>= "3.16.1"} "mirage-clock" {>= "4.2.0"} "yocaml" {= version}