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 1/2] 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} From 7b955aa5826a30869f2aaf88b8a8707ba52df665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Thu, 16 Jan 2025 16:01:52 +0100 Subject: [PATCH 2/2] Add a CHANGES entry --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 3b086e2..37540fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +### Next + +- Update to git-kv 1.0.2 and work around last modified behavior inside a `Git_kv.change_and_push` call (by [reynir](https://reyn.ir)) + + ### v2.1.0 2024-12-14 Nantes (France) - Support for OCaml `5.3.0` (by [kit-ty-kate](https://github.com/kit-ty-kate))