12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091(*
* Copyright (c) 2013-2022 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openLwt.SyntaxincludeXgit_intfletsrc=Logs.Src.create"git.unix"~doc:"logs git's unix events"moduleLog=(valLogs.src_logsrc:Logs.LOG)letremote?ctx?headersuri=let+ctx=matchctxwith|Somex->Lwt.returnx|None->Git_unix.ctx(Happy_eyeballs_lwt.create())inlet(!)fab=fbainletheaders=Option.mapCohttp.Header.to_listheadersinmatchSmart_git.Endpoint.of_stringuriwith|Okedn->letedn=Option.fold~none:edn~some:(!Smart_git.Endpoint.with_headers_if_httpedn)headersin(ctx,edn)|Error(`Msgerr)->Fmt.invalid_arg"remote: %s"errmoduleMaker(G:Irmin_git.G)=structmoduleG=Gtypeendpoint=Mimic.ctx*Smart_git.Endpoint.tmoduleMaker=structmoduleS=Irmin_git.Maker(G)(Git_unix.Sync(G))moduleKV=Irmin_git.KV(G)(Git_unix.Sync(G))moduleRef=Irmin_git.Ref(G)(Git_unix.Sync(G))endmoduleMake(S:Irmin_git.Schema.SwithtypeHash.t=G.hashandtypeNode.t=G.Value.Tree.tandtypeCommit.t=G.Value.Commit.t)=structincludeMaker.S.Make(S)letremote?ctx?headersuri=let+e=remote?ctx?headersuriinEeendmoduleKV(C:Irmin.Contents.S)=structincludeMaker.KV.Make(C)letremote?ctx?headersuri=let+e=remote?ctx?headersuriinEeendmoduleRef(C:Irmin.Contents.S)=structincludeMaker.Ref.Make(C)letremote?ctx?headersuri=let+e=remote?ctx?headersuriinEeendendmoduleFS=structincludeMaker(Git_unix.Store)moduleG=Git_unix.StoreendmoduleMem=structincludeMaker(Irmin_git.Mem)moduleG=Irmin_git.Memend