Skip to content

Commit

Permalink
Merge pull request #16 from samoht/master
Browse files Browse the repository at this point in the history
Cut some dependencies
  • Loading branch information
samoht committed Oct 20, 2014
2 parents e4025df + d272ef5 commit 13e864a
Show file tree
Hide file tree
Showing 52 changed files with 1,247 additions and 1,031 deletions.
6 changes: 3 additions & 3 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# OPAM packages needed to build tests.
OPAM_PACKAGES="camlzip dolog core_kernel cryptokit uri \
cmdliner sha mstruct re ocamlgraph \
OPAM_PACKAGES="camlzip dolog nocrypto uri \
cmdliner mstruct re ocamlgraph \
alcotest lwt \
conduit uri mirage-fs-unix io-page ipaddr"

ppa=avsm/ocaml41+opam11
echo "yes" | sudo add-apt-repository ppa:$ppa
sudo apt-get update -qq
sudo apt-get install -qq ocaml ocaml-native-compilers camlp4-extra opam
sudo apt-get install -qq ocaml ocaml-native-compilers camlp4-extra opam libgmp-dev
export OPAMYES=1

opam init git://github.com/ocaml/opam-repository >/dev/null 2>&1
Expand Down
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.3.0 (2014-10-16)
* Remove the dependency towards 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
persistent store. This allows to store Git repos directly
Expand Down
14 changes: 7 additions & 7 deletions _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.4
Name: git
Version: 1.2.0
Version: 1.3.0
Synopsis: A low-level interface to Git in pure OCaml
Authors: Thomas Gazagnaire
License: ISC
Expand All @@ -24,12 +24,12 @@ Library git
Reference, Sync, Tag, Tree, User, Value,
Object, Object_type, Store, Search, Gri,
Memory, FS
BuildDepends: mstruct, dolog, core_kernel, ocamlgraph,
re.pcre, zip, sha, uri, lwt,
bin_prot.syntax, comparelib.syntax, sexplib.syntax,
BuildDepends: mstruct, dolog, ocamlgraph,
re.pcre, zip, nocrypto, uri, lwt,
sexplib.syntax,
conduit.lwt, uri.services
XMETARequires: mstruct, dolog, core_kernel, ocamlgraph,
re.pcre, zip, sha, uri, lwt,
XMETARequires: mstruct, dolog, ocamlgraph,
re.pcre, zip, nocrypto, uri, lwt,
conduit.lwt, uri.services

Library "git-unix"
Expand Down Expand Up @@ -62,7 +62,7 @@ Executable test_git
MainIs: test.ml
CompiledObject: best
Install: false
BuildDepends: alcotest, git, git.unix, cryptokit,
BuildDepends: alcotest, git, git.unix,
git.mirage, io-page.unix, mirage-fs-unix

Test test_git
Expand Down
29 changes: 6 additions & 23 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 0216bcc876c5cc9c342039b0c69188fb)
# DO NOT EDIT (digest: 8fc45ce2777b5d3ac5333d6a01a5967a)
# 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 @@ -42,67 +42,54 @@
<lib/*.ml{,i}>: pkg_lwt.unix
# Library git-mirage
"lib/git-mirage.cmxs": use_git-mirage
<lib/*.ml{,i}>: pkg_bin_prot.syntax
<lib/*.ml{,i}>: pkg_comparelib.syntax
<lib/*.ml{,i}>: pkg_conduit.lwt
<lib/*.ml{,i}>: pkg_core_kernel
<lib/*.ml{,i}>: pkg_dolog
<lib/*.ml{,i}>: pkg_io-page
<lib/*.ml{,i}>: pkg_lwt
<lib/*.ml{,i}>: pkg_mirage-types.lwt
<lib/*.ml{,i}>: pkg_mstruct
<lib/*.ml{,i}>: pkg_nocrypto
<lib/*.ml{,i}>: pkg_ocamlgraph
<lib/*.ml{,i}>: pkg_re.pcre
<lib/*.ml{,i}>: pkg_sexplib.syntax
<lib/*.ml{,i}>: pkg_sha
<lib/*.ml{,i}>: pkg_uri
<lib/*.ml{,i}>: pkg_uri.services
<lib/*.ml{,i}>: pkg_zip
<lib/*.ml{,i}>: use_git
# Executable ogit
<bin/ogit.{native,byte}>: pkg_bin_prot.syntax
<bin/ogit.{native,byte}>: pkg_cmdliner
<bin/ogit.{native,byte}>: pkg_comparelib.syntax
<bin/ogit.{native,byte}>: pkg_conduit.lwt
<bin/ogit.{native,byte}>: pkg_core_kernel
<bin/ogit.{native,byte}>: pkg_dolog
<bin/ogit.{native,byte}>: pkg_lwt
<bin/ogit.{native,byte}>: pkg_lwt.unix
<bin/ogit.{native,byte}>: pkg_mstruct
<bin/ogit.{native,byte}>: pkg_nocrypto
<bin/ogit.{native,byte}>: pkg_ocamlgraph
<bin/ogit.{native,byte}>: pkg_re.pcre
<bin/ogit.{native,byte}>: pkg_sexplib.syntax
<bin/ogit.{native,byte}>: pkg_sha
<bin/ogit.{native,byte}>: pkg_uri
<bin/ogit.{native,byte}>: pkg_uri.services
<bin/ogit.{native,byte}>: pkg_zip
<bin/ogit.{native,byte}>: use_git
<bin/ogit.{native,byte}>: use_git-unix
<bin/*.ml{,i}>: pkg_bin_prot.syntax
<bin/*.ml{,i}>: pkg_cmdliner
<bin/*.ml{,i}>: pkg_comparelib.syntax
<bin/*.ml{,i}>: pkg_conduit.lwt
<bin/*.ml{,i}>: pkg_core_kernel
<bin/*.ml{,i}>: pkg_dolog
<bin/*.ml{,i}>: pkg_lwt
<bin/*.ml{,i}>: pkg_lwt.unix
<bin/*.ml{,i}>: pkg_mstruct
<bin/*.ml{,i}>: pkg_nocrypto
<bin/*.ml{,i}>: pkg_ocamlgraph
<bin/*.ml{,i}>: pkg_re.pcre
<bin/*.ml{,i}>: pkg_sexplib.syntax
<bin/*.ml{,i}>: pkg_sha
<bin/*.ml{,i}>: pkg_uri
<bin/*.ml{,i}>: pkg_uri.services
<bin/*.ml{,i}>: pkg_zip
<bin/*.ml{,i}>: use_git
<bin/*.ml{,i}>: use_git-unix
# Executable test_git
<lib_test/test.{native,byte}>: pkg_alcotest
<lib_test/test.{native,byte}>: pkg_bin_prot.syntax
<lib_test/test.{native,byte}>: pkg_comparelib.syntax
<lib_test/test.{native,byte}>: pkg_conduit.lwt
<lib_test/test.{native,byte}>: pkg_core_kernel
<lib_test/test.{native,byte}>: pkg_cryptokit
<lib_test/test.{native,byte}>: pkg_dolog
<lib_test/test.{native,byte}>: pkg_io-page
<lib_test/test.{native,byte}>: pkg_io-page.unix
Expand All @@ -111,22 +98,18 @@
<lib_test/test.{native,byte}>: pkg_mirage-fs-unix
<lib_test/test.{native,byte}>: pkg_mirage-types.lwt
<lib_test/test.{native,byte}>: pkg_mstruct
<lib_test/test.{native,byte}>: pkg_nocrypto
<lib_test/test.{native,byte}>: pkg_ocamlgraph
<lib_test/test.{native,byte}>: pkg_re.pcre
<lib_test/test.{native,byte}>: pkg_sexplib.syntax
<lib_test/test.{native,byte}>: pkg_sha
<lib_test/test.{native,byte}>: pkg_uri
<lib_test/test.{native,byte}>: pkg_uri.services
<lib_test/test.{native,byte}>: pkg_zip
<lib_test/test.{native,byte}>: use_git
<lib_test/test.{native,byte}>: use_git-mirage
<lib_test/test.{native,byte}>: use_git-unix
<lib_test/*.ml{,i}>: pkg_alcotest
<lib_test/*.ml{,i}>: pkg_bin_prot.syntax
<lib_test/*.ml{,i}>: pkg_comparelib.syntax
<lib_test/*.ml{,i}>: pkg_conduit.lwt
<lib_test/*.ml{,i}>: pkg_core_kernel
<lib_test/*.ml{,i}>: pkg_cryptokit
<lib_test/*.ml{,i}>: pkg_dolog
<lib_test/*.ml{,i}>: pkg_io-page
<lib_test/*.ml{,i}>: pkg_io-page.unix
Expand All @@ -135,10 +118,10 @@
<lib_test/*.ml{,i}>: pkg_mirage-fs-unix
<lib_test/*.ml{,i}>: pkg_mirage-types.lwt
<lib_test/*.ml{,i}>: pkg_mstruct
<lib_test/*.ml{,i}>: pkg_nocrypto
<lib_test/*.ml{,i}>: pkg_ocamlgraph
<lib_test/*.ml{,i}>: pkg_re.pcre
<lib_test/*.ml{,i}>: pkg_sexplib.syntax
<lib_test/*.ml{,i}>: pkg_sha
<lib_test/*.ml{,i}>: pkg_uri
<lib_test/*.ml{,i}>: pkg_uri.services
<lib_test/*.ml{,i}>: pkg_zip
Expand Down
38 changes: 21 additions & 17 deletions bin/ogit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*)

open Lwt
open Core_kernel.Std
open Cmdliner
open Printf
open Git
open Git_unix

Expand Down Expand Up @@ -130,8 +130,8 @@ let directory =
Arg.(value & pos 1 (some string) None & doc)

let reference =
let parse str = `Ok (Reference.of_string str) in
let print ppf name = Format.pp_print_string ppf (Reference.to_string name) in
let parse str = `Ok (Reference.of_raw str) in
let print ppf name = Format.pp_print_string ppf (Reference.to_raw name) in
parse, print

let branch =
Expand All @@ -154,7 +154,7 @@ let run t =
Lwt_unix.run (
Lwt.catch
(fun () -> t)
(function e -> eprintf "%s\n%!" (Exn.to_string e); exit 1)
(function e -> eprintf "%s\n%!" (Printexc.to_string e); exit 1)
)

(* CAT *)
Expand All @@ -169,7 +169,7 @@ let cat = {
Arg.(required & pos 0 (some string) None & doc) in
let cat_file file =
run begin
let buf = In_channel.read_all file in
Lwt_io.with_file ~mode:Lwt_io.input file Lwt_io.read >>= fun buf ->
let v = Value.input (Mstruct.of_string buf) in
Printf.printf "%s%!" (Value.pretty v);
return_unit
Expand All @@ -189,11 +189,11 @@ let ls_remote = {
S.create () >>= fun t ->
Sync.ls t remote >>= fun references ->
Printf.printf "From %s\n" (Gri.to_string remote);
let print ~key:ref ~data:sha1 =
let print ref sha1 =
Printf.printf "%s %s\n"
(SHA.Commit.to_hex sha1)
(Reference.to_string ref) in
Map.iter ~f:print references;
(Reference.to_raw ref) in
Reference.Map.iter print references;
return_unit
end in
Term.(mk ls $ backend $ remote)
Expand All @@ -217,7 +217,7 @@ let ls_files = {
printf "%s" (Cache.pretty cache)
else
List.iter
~f:(fun e -> Printf.printf "%s\n" e.Cache.name)
(fun e -> Printf.printf "%s\n" e.Cache.name)
cache.Cache.entries;
return_unit
end in
Expand All @@ -242,8 +242,8 @@ let read_tree = {
begin
let (/) = Filename.concat in
let ref = "refs" / "heads" / commit_str in
if List.exists refs ~f:(fun r -> Reference.to_string r = ref) then
S.read_reference_exn t (Reference.of_string ref)
if List.exists (fun r -> Reference.to_raw r = ref) refs then
S.read_reference_exn t (Reference.of_raw ref)
else
return (SHA.Commit.of_hex commit_str)
end >>= fun commit ->
Expand Down Expand Up @@ -329,8 +329,8 @@ let push = {
S.create () >>= fun t ->
S.read_reference t branch >>= fun b ->
let branch = match b with
| None -> Reference.of_string
("refs/heads/" ^ Reference.to_string branch)
| None -> Reference.of_raw
("refs/heads/" ^ Reference.to_raw branch)
| Some _ -> branch in
Sync.push t ~branch remote >>= fun s ->
printf "%s\n" (Result.pretty_push s);
Expand All @@ -352,7 +352,11 @@ let graph = {
let module Graph = Global_graph.Make(S) in
run begin
S.create () >>= fun t ->
Graph.to_dot t file
let buf = Buffer.create 1024 in
Graph.to_dot t buf >>= fun () ->
Lwt_io.with_file ~mode:Lwt_io.output file (fun oc ->
Lwt_io.write oc (Buffer.contents buf)
)
end in
Term.(mk graph $ backend $ file)
}
Expand All @@ -373,10 +377,10 @@ let help = {
| None -> `Help (`Pager, None)
| Some topic ->
let topics = "topics" :: cmds in
let conv, _ = Arg.enum (List.rev_map ~f:(fun s -> (s, s)) topics) in
let conv, _ = Arg.enum (List.rev_map (fun s -> (s, s)) topics) in
match conv topic with
| `Error e -> `Error (false, e)
| `Ok t when t = "topics" -> List.iter ~f:print_endline cmds; `Ok ()
| `Ok t when t = "topics" -> List.iter print_endline cmds; `Ok ()
| `Ok t -> `Help (man_format, Some t) in
Term.(ret (pure help $Term.man_format $Term.choice_names $topic))
}
Expand Down Expand Up @@ -415,7 +419,7 @@ let default =
~doc
~man

let commands = List.map ~f:command [
let commands = List.map command [
cat;
ls_remote;
ls_files;
Expand Down
Loading

0 comments on commit 13e864a

Please sign in to comment.