Merge pull request 'add-push' (#14) from add-push into main
Reviewed-on: https://git.robur.io/robur/git-kv/pulls/14
This commit is contained in:
commit
7323b8f065
3 changed files with 10 additions and 2 deletions
|
@ -11,6 +11,7 @@ depends: [
|
||||||
"dune" {>= "2.0.0"}
|
"dune" {>= "2.0.0"}
|
||||||
"git" {>= "3.9.0"}
|
"git" {>= "3.9.0"}
|
||||||
"mirage-kv" {>= "4.0.0"}
|
"mirage-kv" {>= "4.0.0"}
|
||||||
|
"git-unix"
|
||||||
"ptime"
|
"ptime"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,8 @@ let pull t =
|
||||||
Store.Ref.resolve t.store t.branch >>= fun r ->
|
Store.Ref.resolve t.store t.branch >>= fun r ->
|
||||||
let head =
|
let head =
|
||||||
Result.map_error
|
Result.map_error
|
||||||
(fun e -> `Msg (Fmt.str "error resolving branch %s: %a"
|
(fun e -> `Msg (Fmt.str "error resolving branch %a: %a"
|
||||||
(Git.Reference.to_string t.branch)
|
Git.Reference.pp t.branch
|
||||||
Store.pp_error e))
|
Store.pp_error e))
|
||||||
r |> to_invalid
|
r |> to_invalid
|
||||||
in
|
in
|
||||||
|
@ -92,6 +92,12 @@ let pull t =
|
||||||
t.head <- Some head;
|
t.head <- Some head;
|
||||||
Lwt.return (Ok diff)
|
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 connect ctx endpoint =
|
||||||
let open Lwt.Infix in
|
let open Lwt.Infix in
|
||||||
init_store () >>= fun store ->
|
init_store () >>= fun store ->
|
||||||
|
|
|
@ -22,4 +22,5 @@ type change = [ `Add of key
|
||||||
| `Change of key ]
|
| `Change of key ]
|
||||||
|
|
||||||
val pull : t -> (change list, [> `Msg of string ]) result Lwt.t
|
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
|
val size : t -> key -> (int, error) result Lwt.t
|
||||||
|
|
Loading…
Reference in a new issue