From 36ceb8a0cdc8392f5b4f30e33420eb437ad69d3b Mon Sep 17 00:00:00 2001 From: Romain Calascibetta Date: Wed, 19 Oct 2022 11:37:12 +0200 Subject: [PATCH 1/2] The application requires git-unix --- git-kv.opam | 1 + 1 file changed, 1 insertion(+) diff --git a/git-kv.opam b/git-kv.opam index a239187..6e15412 100644 --- a/git-kv.opam +++ b/git-kv.opam @@ -11,6 +11,7 @@ depends: [ "dune" {>= "2.0.0"} "git" {>= "3.9.0"} "mirage-kv" {>= "4.0.0"} + "git-unix" "ptime" ] From 3ff46e50ac7c070726be819f3a551d9416337bfc Mon Sep 17 00:00:00 2001 From: Romain Calascibetta Date: Wed, 19 Oct 2022 11:37:41 +0200 Subject: [PATCH 2/2] Implement the push function --- src/git_kv.ml | 10 ++++++++-- src/git_kv.mli | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/git_kv.ml b/src/git_kv.ml index 3232afb..c4ce12a 100644 --- a/src/git_kv.ml +++ b/src/git_kv.ml @@ -83,8 +83,8 @@ let pull t = Store.Ref.resolve t.store t.branch >>= fun r -> let head = Result.map_error - (fun e -> `Msg (Fmt.str "error resolving branch %s: %a" - (Git.Reference.to_string t.branch) + (fun e -> `Msg (Fmt.str "error resolving branch %a: %a" + Git.Reference.pp t.branch Store.pp_error e)) r |> to_invalid in @@ -92,6 +92,12 @@ let pull t = t.head <- Some head; Lwt.return (Ok diff) +let push t = + let open Lwt.Infix in + Sync.push ~capabilities ~ctx:t.ctx t.edn t.store [ `Update (t.branch, t.branch) ] + >|= Result.map_error (fun err -> `Msg (Fmt.str "error pushing branch %a: %a" + Git.Reference.pp t.branch Sync.pp_error err)) + let connect ctx endpoint = let open Lwt.Infix in init_store () >>= fun store -> diff --git a/src/git_kv.mli b/src/git_kv.mli index f9caac7..8bc0b36 100644 --- a/src/git_kv.mli +++ b/src/git_kv.mli @@ -22,4 +22,5 @@ type change = [ `Add of key | `Change of key ] val pull : t -> (change list, [> `Msg of string ]) result Lwt.t +val push : t -> (unit, [> `Msg of string ]) result Lwt.t val size : t -> key -> (int, error) result Lwt.t