Skip to content

Commit

Permalink
Merge pull request #26 from mbarbin/remove-eio-writer
Browse files Browse the repository at this point in the history
Remove eio writer
  • Loading branch information
mbarbin authored Sep 29, 2024
2 parents 5fbdf1b + cfe3dbb commit 14f307c
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 295 deletions.
14 changes: 14 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 0.0.8 (unreleased)

### Added

### Changed

- Remove `eio-writer` dependency in `vcs-command`.

### Deprecated

### Fixed

### Removed

## 0.0.7 (2024-09-20)

### Changed
Expand Down
6 changes: 1 addition & 5 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@
(>= 0.0.5))
(cmdlang-cmdliner-runner
(>= 0.0.5))
(cmdlang-to-cmdliner
(>= 0.0.5))
(cmdliner
(= 1.3.0))
(eio
Expand All @@ -143,7 +141,7 @@
(>= 0.0.5))
(fpath
(>= 0.7.3))
(fpath-base
(fpath-sexp0
(>= 0.2.0))
(ppx_compare
(and
Expand Down Expand Up @@ -180,8 +178,6 @@
(vcs-arg
(= :version))
(vcs-git-eio
(= :version))
(vcs-private-libs-eio
(= :version))))

(package
Expand Down
4 changes: 1 addition & 3 deletions lib/vcs/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
-open
Base
-open
Fpath_base
-open
Or_error.Let_syntax)
Fpath_base)
(libraries base fpath fpath-base provider)
(instrumentation
(backend bisect_ppx))
Expand Down
1 change: 1 addition & 0 deletions lib/vcs/src/for_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
(*******************************************************************************)

let init vcs ~path =
let open Or_error.Let_syntax in
let%bind repo_root = Vcs_or_error.init vcs ~path in
let%bind () =
Vcs_or_error.set_user_name vcs ~repo_root ~user_name:(User_name.v "Test User")
Expand Down
5 changes: 3 additions & 2 deletions lib/vcs/src/vcs0.ml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let current_revision (Provider.T { t; handler }) ~repo_root =
let commit (Provider.T { t; handler }) ~repo_root ~commit_message =
let module R = (val Provider.Handler.lookup handler ~trait:Trait.Rev_parse) in
let module C = (val Provider.Handler.lookup handler ~trait:Trait.Commit) in
(let%bind () = C.commit t ~repo_root ~commit_message in
(let%bind.Or_error () = C.commit t ~repo_root ~commit_message in
R.current_revision t ~repo_root)
|> of_result ~step:(lazy [%sexp "Vcs.commit", { repo_root : Repo_root.t }])
;;
Expand Down Expand Up @@ -130,7 +130,8 @@ let graph (Provider.T { t; handler }) ~repo_root =
let module L = (val Provider.Handler.lookup handler ~trait:Trait.Log) in
let module R = (val Provider.Handler.lookup handler ~trait:Trait.Refs) in
let graph = Graph.create () in
(let%bind log = L.all t ~repo_root in
(let open Or_error.Let_syntax in
let%bind log = L.all t ~repo_root in
let%bind refs = R.show_ref t ~repo_root in
Graph.add_nodes graph ~log;
Graph.set_refs graph ~refs;
Expand Down
4 changes: 1 addition & 3 deletions lib/vcs/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
-open
Fpath_base
-open
Expect_test_helpers_base
-open
Or_error.Let_syntax)
Expect_test_helpers_base)
(libraries
base
eio
Expand Down
2 changes: 0 additions & 2 deletions lib/vcs_arg/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
-open
Fpath_base
-open
Or_error.Let_syntax
-open
Cmdlang)
(libraries base cmdlang eio fpath fpath-base unix vcs vcs-git-eio)
(instrumentation
Expand Down
16 changes: 2 additions & 14 deletions lib/vcs_command/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,10 @@
-open
Base
-open
Fpath_base
-open
Vcs_eio_writer
Fpath_sexp0
-open
Cmdlang)
(libraries
base
cmdlang
eio
eio_main
fpath
fpath-base
vcs
vcs-arg
vcs-git-eio
vcs-private-libs-eio.eio-writer)
(libraries base cmdlang eio eio_main fpath-sexp0 vcs vcs-arg vcs-git-eio)
(instrumentation
(backend bisect_ppx))
(lint
Expand Down
41 changes: 20 additions & 21 deletions lib/vcs_command/src/vcs_command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
the name the associated function has in the [V.S] interface, prepending the
suffix "_cmd". *)

let print_sexp sexp = Stdlib.print_endline (Sexp.to_string_hum sexp)

let add_cmd =
Command.make
~summary:"add a file to the index"
Expand Down Expand Up @@ -50,7 +52,7 @@ let commit_cmd =
Vcs_arg.initialize ~env ~config
in
let rev = Vcs.commit vcs ~repo_root ~commit_message in
if not quiet then Eio_writer.print_sexp ~env [%sexp (rev : Vcs.Rev.t)];
if not quiet then print_sexp [%sexp (rev : Vcs.Rev.t)];
())
;;

Expand All @@ -64,7 +66,7 @@ let current_branch_cmd =
Vcs_arg.initialize ~env ~config
in
let branch = Vcs.current_branch vcs ~repo_root in
Eio_writer.print_sexp ~env [%sexp (branch : Vcs.Branch_name.t)];
print_sexp [%sexp (branch : Vcs.Branch_name.t)];
())
;;

Expand All @@ -78,7 +80,7 @@ let current_revision_cmd =
Vcs_arg.initialize ~env ~config
in
let rev = Vcs.current_revision vcs ~repo_root in
Eio_writer.print_sexp ~env [%sexp (rev : Vcs.Rev.t)];
print_sexp [%sexp (rev : Vcs.Rev.t)];
())
;;

Expand All @@ -97,8 +99,8 @@ let git_cmd =
let { Vcs.Git.Output.exit_code; stdout; stderr } =
Vcs.git vcs ~repo_root ~args ~f:Fn.id
in
Eio_writer.print_string ~env stdout;
Eio_writer.prerr_string ~env stderr;
Stdlib.print_string stdout;
Stdlib.prerr_string stderr;
if exit_code <> 0 then Stdlib.exit exit_code)
;;

Expand All @@ -115,8 +117,7 @@ let init_cmd =
in
let path = Vcs_arg.resolve path ~context in
let repo_root = Vcs.init vcs ~path in
if not quiet
then Eio_writer.print_sexp ~env [%sexp (repo_root : Vcs.Repo_root.t)] [@coverage off];
if not quiet then print_sexp [%sexp (repo_root : Vcs.Repo_root.t)] [@coverage off];
())
;;

Expand All @@ -132,7 +133,7 @@ let load_file_cmd =
in
let path = Vcs_arg.resolve path ~context in
let contents = Vcs.load_file vcs ~path in
Eio_writer.print_string ~env (contents :> string);
Stdlib.print_string (contents :> string);
())
;;

Expand All @@ -149,9 +150,8 @@ let ls_files_cmd =
let below = Vcs_arg.resolve below ~context in
let below = Option.value below ~default:Vcs.Path_in_repo.root in
let files = Vcs.ls_files vcs ~repo_root ~below in
Eio_writer.with_flow (Eio.Stdenv.stdout env) (fun w ->
List.iter files ~f:(fun file ->
Eio_writer.write_line w (Vcs.Path_in_repo.to_string file)));
List.iter files ~f:(fun file ->
Stdlib.print_endline (Vcs.Path_in_repo.to_string file));
())
;;

Expand All @@ -165,7 +165,7 @@ let log_cmd =
Vcs_arg.initialize ~env ~config
in
let log = Vcs.log vcs ~repo_root in
Eio_writer.print_sexp ~env [%sexp (log : Vcs.Log.t)];
print_sexp [%sexp (log : Vcs.Log.t)];
())
;;

Expand All @@ -181,7 +181,7 @@ let name_status_cmd =
Vcs_arg.initialize ~env ~config
in
let name_status = Vcs.name_status vcs ~repo_root ~changed:(Between { src; dst }) in
Eio_writer.print_sexp ~env [%sexp (name_status : Vcs.Name_status.t)];
print_sexp [%sexp (name_status : Vcs.Name_status.t)];
())
;;

Expand All @@ -197,7 +197,7 @@ let num_status_cmd =
Vcs_arg.initialize ~env ~config
in
let num_status = Vcs.num_status vcs ~repo_root ~changed:(Between { src; dst }) in
Eio_writer.print_sexp ~env [%sexp (num_status : Vcs.Num_status.t)];
print_sexp [%sexp (num_status : Vcs.Num_status.t)];
())
;;

Expand Down Expand Up @@ -225,7 +225,7 @@ let refs_cmd =
Vcs_arg.initialize ~env ~config
in
let refs = Vcs.refs vcs ~repo_root in
Eio_writer.print_sexp ~env [%sexp (refs : Vcs.Refs.t)];
print_sexp [%sexp (refs : Vcs.Refs.t)];
())
;;

Expand Down Expand Up @@ -281,10 +281,9 @@ let show_file_at_rev_cmd =
let path = Vcs_arg.resolve path ~context in
let result = Vcs.show_file_at_rev vcs ~repo_root ~rev ~path in
(match result with
| `Present contents -> Eio_writer.print_string ~env (contents :> string)
| `Present contents -> Stdlib.print_string (contents :> string)
| `Absent ->
Eio_writer.eprintf
~env
Stdlib.Printf.eprintf
"Path '%s' does not exist in '%s'"
(Vcs.Path_in_repo.to_string path)
(Vcs.Rev.to_string rev));
Expand All @@ -301,7 +300,7 @@ let graph_cmd =
Vcs_arg.initialize ~env ~config
in
let graph = Vcs.graph vcs ~repo_root in
Eio_writer.print_sexp ~env [%sexp (Vcs.Graph.summary graph : Vcs.Graph.Summary.t)];
print_sexp [%sexp (Vcs.Graph.summary graph : Vcs.Graph.Summary.t)];
())
;;

Expand Down Expand Up @@ -335,7 +334,7 @@ let branch_revision_cmd =
"Branch not found"
[%sexp { branch_name : Vcs.Branch_name.t }] [@coverage off]
in
Eio_writer.print_sexp ~env [%sexp (rev : Vcs.Rev.t)];
print_sexp [%sexp (rev : Vcs.Rev.t)];
())
;;

Expand All @@ -360,7 +359,7 @@ let greatest_common_ancestors_cmd =
Vcs.Graph.greatest_common_ancestors graph nodes
|> List.map ~f:(fun node -> Vcs.Graph.rev graph node)
in
Eio_writer.print_sexp ~env [%sexp (gca : Vcs.Rev.t list)];
print_sexp [%sexp (gca : Vcs.Rev.t list)];
())
;;

Expand Down
2 changes: 0 additions & 2 deletions lib/vcs_git_eio/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
-open
Fpath_base
-open
Or_error.Let_syntax
-open
Vcs_eio_process)
(libraries
base
Expand Down
4 changes: 1 addition & 3 deletions lib/vcs_git_eio/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
-open
Fpath_base
-open
Expect_test_helpers_base
-open
Or_error.Let_syntax)
Expect_test_helpers_base)
(libraries
base
eio
Expand Down
4 changes: 1 addition & 3 deletions lib/vcs_test_helpers/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
-open
Fpath_base
-open
Expect_test_helpers_base
-open
Or_error.Let_syntax)
Expect_test_helpers_base)
(libraries
base
eio
Expand Down
4 changes: 1 addition & 3 deletions test/expect/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
-open
Fpath_base
-open
Expect_test_helpers_base
-open
Or_error.Let_syntax)
Expect_test_helpers_base)
(libraries
base
eio
Expand Down
5 changes: 3 additions & 2 deletions test/expect/nonraising_unit_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ let%expect_test "num stat without lines" =
|}];
let commit_file ~path ~file_contents =
let result =
let open Or_error.Let_syntax in
let%bind () =
Vcs.Or_error.save_file
vcs
Expand All @@ -127,7 +128,7 @@ let%expect_test "num stat without lines" =
print_s [%sexp (mock_rev : Vcs.Rev.t)];
[%expect {| 1185512b92d612b25613f2e5b473e5231185512b |}];
let result =
let%bind () =
let%bind.Or_error () =
Vcs.Or_error.rename_current_branch vcs ~repo_root ~to_:(Vcs.Branch_name.v "branch")
in
Vcs.Or_error.current_branch vcs ~repo_root
Expand All @@ -136,7 +137,7 @@ let%expect_test "num stat without lines" =
[%expect {| (Ok branch) |}];
Vcs.rename_current_branch vcs ~repo_root ~to_:Vcs.Branch_name.main;
let result =
let%map rev = Vcs.Or_error.current_revision vcs ~repo_root in
let%map.Or_error rev = Vcs.Or_error.current_revision vcs ~repo_root in
Vcs.Mock_revs.to_mock mock_revs ~rev
in
print_s [%sexp (result : Vcs.Rev.t Or_error.t)];
Expand Down
4 changes: 1 addition & 3 deletions vcs-command.opam
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ depends: [
"base" {>= "v0.17" & < "v0.18"}
"cmdlang" {>= "0.0.5"}
"cmdlang-cmdliner-runner" {>= "0.0.5"}
"cmdlang-to-cmdliner" {>= "0.0.5"}
"cmdliner" {= "1.3.0"}
"eio" {>= "1.0"}
"eio_main" {>= "1.0"}
"err" {>= "0.0.5"}
"fpath" {>= "0.7.3"}
"fpath-base" {>= "0.2.0"}
"fpath-sexp0" {>= "0.2.0"}
"ppx_compare" {>= "v0.17" & < "v0.18"}
"ppx_enumerate" {>= "v0.17" & < "v0.18"}
"ppx_hash" {>= "v0.17" & < "v0.18"}
Expand All @@ -31,7 +30,6 @@ depends: [
"vcs" {= version}
"vcs-arg" {= version}
"vcs-git-eio" {= version}
"vcs-private-libs-eio" {= version}
"odoc" {with-doc}
]
build: [
Expand Down
21 changes: 0 additions & 21 deletions vendor/eio-writer/LICENSE

This file was deleted.

Loading

0 comments on commit 14f307c

Please sign in to comment.