Skip to content

Commit

Permalink
Merge pull request #24 from avsm/conduit-0.6
Browse files Browse the repository at this point in the history
Port to Conduit 0.6.0 API
  • Loading branch information
avsm committed Nov 20, 2014
2 parents a7d115b + 2eb2c89 commit e5b9794
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 28 deletions.
17 changes: 9 additions & 8 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
1.3.1
* Depend on ocaml-hex
1.4.0 (2014-11-20):
* Port to Conduit 0.6.0 API.
* Depend on `ocaml-hex`

1.3.0 (2014-10-16)
* Remove the dependency towards core_kernel
* Use ocaml-nocrypto instead of ocaml-sha1
* Remove the dependency on `core_kernel`
* Use `ocaml-nocrypto` instead of `ocaml-sha1`

1.2.0: (2014-06-10)
* Can consume Mirage's V1_LWT.FS signature to generate a
* Can consume Mirage's `V1_LWT.FS` signature to generate a
persistent store. This allows to store Git repos directly
inside raw block devices (no need of filesystem anymore).
* Minor API refactoring to abstract the unix layer cleanly
* Minor API refactoring to abstract the Unix layer cleanly.
* Expose a filesystem functor to create filesystem backends
independent of unix
* Simplify the ocamlfind packages: there's only git and git.unix
independent of Unix.
* Simplify the ocamlfind packages: there's only `git` and `git.unix`.

1.1.0: (2014-06-02)
* Support for push (not optimized at all)
Expand Down
4 changes: 2 additions & 2 deletions _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.4
Name: git
Version: 1.3.1
Version: 1.4.0
Synopsis: A low-level interface to Git in pure OCaml
Authors: Thomas Gazagnaire
License: ISC
Expand Down Expand Up @@ -33,7 +33,7 @@ Library "git-unix"
FindlibParent: git
Findlibname: unix
Modules: Git_unix
BuildDepends: git, lwt.unix
BuildDepends: git, lwt.unix, conduit.lwt-unix

Library "git-mirage"
Build$: flag(mirage)
Expand Down
7 changes: 6 additions & 1 deletion _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: a4d4195be44b131449bbb09884fadca0)
# DO NOT EDIT (digest: b342839f4a03056605b18b5846a1e55a)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
Expand Down Expand Up @@ -41,6 +41,7 @@ true: annot, bin_annot
"lib/FS.cmx": for-pack(Git)
# Library git-unix
"lib/git-unix.cmxs": use_git-unix
<lib/*.ml{,i,y}>: pkg_conduit.lwt-unix
<lib/*.ml{,i,y}>: pkg_lwt.unix
# Library git-mirage
"lib/git-mirage.cmxs": use_git-mirage
Expand All @@ -60,6 +61,7 @@ true: annot, bin_annot
# Executable ogit
<bin/ogit.{native,byte}>: pkg_cmdliner
<bin/ogit.{native,byte}>: pkg_conduit.lwt
<bin/ogit.{native,byte}>: pkg_conduit.lwt-unix
<bin/ogit.{native,byte}>: pkg_dolog
<bin/ogit.{native,byte}>: pkg_hex
<bin/ogit.{native,byte}>: pkg_lwt
Expand All @@ -74,6 +76,7 @@ true: annot, bin_annot
<bin/ogit.{native,byte}>: use_git-unix
<bin/*.ml{,i,y}>: pkg_cmdliner
<bin/*.ml{,i,y}>: pkg_conduit.lwt
<bin/*.ml{,i,y}>: pkg_conduit.lwt-unix
<bin/*.ml{,i,y}>: pkg_dolog
<bin/*.ml{,i,y}>: pkg_hex
<bin/*.ml{,i,y}>: pkg_lwt
Expand All @@ -89,6 +92,7 @@ true: annot, bin_annot
# Executable test_git
<lib_test/test.{native,byte}>: pkg_alcotest
<lib_test/test.{native,byte}>: pkg_conduit.lwt
<lib_test/test.{native,byte}>: pkg_conduit.lwt-unix
<lib_test/test.{native,byte}>: pkg_dolog
<lib_test/test.{native,byte}>: pkg_hex
<lib_test/test.{native,byte}>: pkg_io-page
Expand All @@ -108,6 +112,7 @@ true: annot, bin_annot
<lib_test/test.{native,byte}>: use_git-unix
<lib_test/*.ml{,i,y}>: pkg_alcotest
<lib_test/*.ml{,i,y}>: pkg_conduit.lwt
<lib_test/*.ml{,i,y}>: pkg_conduit.lwt-unix
<lib_test/*.ml{,i,y}>: pkg_dolog
<lib_test/*.ml{,i,y}>: pkg_hex
<lib_test/*.ml{,i,y}>: pkg_io-page
Expand Down
4 changes: 2 additions & 2 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: c072aed376ca0c284b937c22d49af750)
# DO NOT EDIT (digest: 0816239473a08d14cba1a7b0dc361851)
version = "1.3.1"
description = "A low-level interface to Git in pure OCaml"
requires =
Expand All @@ -12,7 +12,7 @@ exists_if = "git.cma"
package "unix" (
version = "1.3.1"
description = "A low-level interface to Git in pure OCaml"
requires = "git lwt.unix"
requires = "git lwt.unix conduit.lwt-unix"
archive(byte) = "git-unix.cma"
archive(byte, plugin) = "git-unix.cma"
archive(native) = "git-unix.cmxa"
Expand Down
25 changes: 15 additions & 10 deletions lib/git_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,26 @@ module M = struct
Lwt.finalize
(fun () -> fn (p#stdout, p#stdin))
(fun () -> let _ = p#close in return_unit)
| _ ->
(* XXX: make it work for smart-HTTP *)
(* XXX: make it work over SSL *)
let mode = `TCP in
let service = string_of_int 9418 in
Log.debugf "Connecting to %s [%s]" host service;
Lwt_unix_conduit.connect ~mode ~host ~service () >>= fun (ic, oc) ->
| Some "git" ->
Log.debugf "Connecting to %s" (Uri.to_string uri);
let resolver = Resolver_lwt_unix.system in
Resolver_lwt.resolve_uri ~uri resolver >>= fun endp ->
let ctx = Conduit_lwt_unix.default_ctx in
Conduit_lwt_unix.endp_to_client ~ctx endp >>= fun client ->
Conduit_lwt_unix.connect ~ctx client >>= fun (flow, ic, oc) ->
Lwt.finalize
(fun () ->
begin match init with
| None -> return_unit
| Some s -> write oc s
end >>= fun () ->
fn (ic, oc))
(fun () -> Lwt_unix_conduit.close ic oc; return_unit)
(fun () -> Lwt_io.close ic)
| Some x ->
(* XXX: make it work for smart-HTTP *)
(* XXX: make it work over SSL *)
fail (Failure ("Scheme " ^ x ^ " not supported yet"))
| None -> fail (Failure ("Must supply a scheme like git://"))

let read_all ic =
let len = 1024 in
Expand Down Expand Up @@ -143,8 +148,8 @@ module D = struct
mkdir (Filename.dirname file) >>= fun () ->
Lwt_pool.use openfile_pool (fun () ->
Lwt_unix.(openfile file [O_WRONLY; O_NONBLOCK; O_CREAT; O_TRUNC] 0o644) >>= fun fd ->
catch
(fun () -> fn fd >>= fun () -> Lwt_unix.close fd)
Lwt.finalize
(fun () -> fn fd)
(fun _ -> Lwt_unix.close fd))

let write_file file b =
Expand Down
2 changes: 1 addition & 1 deletion opam
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ depends: [
"ocamlgraph"
"lwt" {>= "2.4.5"}
"hex"
"conduit" {= "0.5.1"}
"conduit" {>= "0.6.0"}
"alcotest" {test}
"mirage-fs-unix" {test}
]
Expand Down
9 changes: 5 additions & 4 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.4.1 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: 8c61332aa08f0955eeecaf6f97e8b1f9) *)
(* DO NOT EDIT (digest: e4ba2fb3a416a01c4650b8e7cf43aa59) *)
(*
Regenerated by OASIS v0.4.5
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -7019,7 +7019,8 @@ let setup_t =
bs_build_depends =
[
InternalLibrary "git";
FindlibPackage ("lwt.unix", None)
FindlibPackage ("lwt.unix", None);
FindlibPackage ("conduit.lwt-unix", None)
];
bs_build_tools = [ExternalTool "ocamlbuild"];
bs_c_sources = [];
Expand Down Expand Up @@ -7218,14 +7219,14 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.5";
oasis_digest = Some "Úé²\140¹\154*©¾Ô»\017B\141~\138";
oasis_digest = Some "ªF´brÐüãV\132\157i¶8²\138";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
};;

let setup () = BaseSetup.setup setup_t;;

# 7230 "setup.ml"
# 7231 "setup.ml"
(* OASIS_STOP *)
let () = setup ();;

0 comments on commit e5b9794

Please sign in to comment.