Skip to content

Commit

Permalink
Merge pull request #21 from mbarbin/vcs-git-eio
Browse files Browse the repository at this point in the history
vcs-git-eio & vcs-git-provider
  • Loading branch information
mbarbin authored Sep 20, 2024
2 parents 882c054 + 3529550 commit 02224aa
Show file tree
Hide file tree
Showing 87 changed files with 127 additions and 111 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Changed

- Rename `vcs-git-cli` to `vcs-git-provider` (breaking change).
- Rename `vcs-git` to `vcs-git-eio` (breaking change).
- Rename `tree` to `graph` to designate the commit graph of a repository (breaking change).
- Upgrade to `cmdlang.0.0.5`.

Expand Down
16 changes: 8 additions & 8 deletions doc/docs/design/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ The `vcs` repository contains several components:
stateDiagram-v2
vcs : vcs *
user : user-lib *
vcs_git_cli : vcs-git-cli
vcs_git_provider : vcs-git-provider
executable : executable (eio)
provider : vcs-git
provider : vcs-git-eio
runtime : eio
vcs --> user
user --> executable
vcs_git_cli --> provider
vcs_git_provider --> provider
runtime --> provider
provider --> executable
```
Expand All @@ -33,21 +33,21 @@ stateDiagram-v2
Also marked with a * to indicate no runtime dependencies.
- **executable**: A placeholder for a runtime component based on `user-lib` that
commits to a specific provider and concurrency model.
- **vcs-git-cli**: A IO-free library that parses the output of a `git` cli process.
- **vcs-git**: An instantiation of `Vcs_git_cli` based on an `Eio` runtime.
- **vcs-git-blocking**: An instantiation of `Vcs_git_cli` based on the OCaml `Stdlib`.
- **vcs-git-provider**: A IO-free library that parses the output of a `git` cli process.
- **vcs-git-eio**: An instantiation of `Vcs_git_provider` based on an `Eio` runtime.
- **vcs-git-blocking**: An instantiation of `Vcs_git_provider` based on the OCaml `Stdlib`.

```mermaid
stateDiagram-v2
vcs : vcs *
user : user-lib *
vcs_git_cli : vcs-git-cli
vcs_git_provider : vcs-git-provider
executable : executable (blocking)
provider : vcs-git-blocking
runtime : stdlib
vcs --> user
user --> executable
vcs_git_cli --> provider
vcs_git_provider --> provider
runtime --> provider
provider --> executable
```
Expand Down
21 changes: 11 additions & 10 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
(>= 0.33))
(vcs
(= :version))
(vcs-git
(vcs-git-eio
(= :version))))

(package
Expand Down Expand Up @@ -181,13 +181,13 @@
(= :version))
(vcs-arg
(= :version))
(vcs-git
(vcs-git-eio
(= :version))
(vcs-private-libs-eio
(= :version))))

(package
(name vcs-git-cli)
(name vcs-git-provider)
(synopsis "An IO-free library that parses the output of Git commands")
(depends
(ocaml
Expand Down Expand Up @@ -234,8 +234,9 @@
(= :version))))

(package
(name vcs-git)
(synopsis "A Git provider for Vcs based on Vcs_git_cli for Eio programs")
(name vcs-git-eio)
(synopsis
"A Git provider for Vcs based on Vcs_git_provider for Eio programs")
(depends
(ocaml
(>= 5.2))
Expand Down Expand Up @@ -283,15 +284,15 @@
(>= 0.0.8))
(vcs
(= :version))
(vcs-git-cli
(vcs-git-provider
(= :version))
(vcs-private-libs-eio
(= :version))))

(package
(name vcs-git-blocking)
(synopsis
"A Git provider for Vcs based on Vcs_git_cli for blocking programs")
"A Git provider for Vcs based on Vcs_git_provider for blocking programs")
(depends
(ocaml
(>= 5.2))
Expand Down Expand Up @@ -337,7 +338,7 @@
(>= 0.0.8))
(vcs
(= :version))
(vcs-git-cli
(vcs-git-provider
(= :version))))

(package
Expand Down Expand Up @@ -453,11 +454,11 @@
(= :version))
(vcs-command
(= :version))
(vcs-git
(vcs-git-eio
(= :version))
(vcs-git-blocking
(= :version))
(vcs-git-cli
(vcs-git-provider
(= :version))
(vcs-private-libs-base
(= :version))
Expand Down
2 changes: 1 addition & 1 deletion example/dune
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
fpath
fpath-base
vcs
vcs_git
vcs_git_eio
vcs_git_blocking
vcs_test_helpers)
(instrumentation
Expand Down
2 changes: 1 addition & 1 deletion example/hello_error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
let%expect_test "hello error" =
Eio_main.run
@@ fun env ->
let vcs = Vcs_git.create ~env in
let vcs = Vcs_git_eio.create ~env in
let invalid_path = Absolute_path.v "/invalid/path" in
let redact_sexp sexp =
(* Because the actual error may become too brittle overtime, we actually
Expand Down
2 changes: 1 addition & 1 deletion example/hello_git_cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let%expect_test "hello cli" =
@@ fun env ->
Eio.Switch.run
@@ fun sw ->
let vcs = Vcs_git.create ~env in
let vcs = Vcs_git_eio.create ~env in
let repo_root = Vcs_test_helpers.init_temp_repo ~env ~sw ~vcs in
let hello_file = Vcs.Path_in_repo.v "hello.txt" in
Vcs.save_file
Expand Down
2 changes: 1 addition & 1 deletion example/hello_vcs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let%expect_test "hello commit" =
(* To use the [Vcs] API, you need a [vcs] value, which you must obtain from a
provider. We're using [Vcs_git] for this here. It is a provider based on
[Eio] and running the [git] command line as an external process. *)
let vcs = Vcs_git.create ~env in
let vcs = Vcs_git_eio.create ~env in
(* The next step takes care of creating a fresh repository. We make use of a
helper library to encapsulate the required steps. *)
let repo_root = Vcs_test_helpers.init_temp_repo ~env ~sw ~vcs in
Expand Down
2 changes: 1 addition & 1 deletion lib/vcs/src/vcs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type -'a t = 'a Vcs0.t

(** [create provider] returns a [vcs] that implements a given set of traits.
Typical users do not use [create] directly, but rather will rely on an
actual provider. See for example [Vcs_git.create]. *)
actual provider. See for example [Vcs_git_eio.create]. *)
val create : 'a Provider.t -> 'a t

(** {1 Error handling}
Expand Down
2 changes: 1 addition & 1 deletion lib/vcs/test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
fpath
fpath-base
vcs
vcs_git_cli)
vcs_git_provider)
(instrumentation
(backend bisect_ppx))
(lint
Expand Down
4 changes: 2 additions & 2 deletions lib/vcs/test/test__graph.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ let%expect_test "graph" =
let path = Eio.Path.(Eio.Stdenv.fs env / "super-master-mind.log") in
let contents = Eio.Path.load path in
let lines = String.split_lines contents in
List.map lines ~f:(fun line -> Vcs_git_cli.Log.parse_log_line_exn ~line)
List.map lines ~f:(fun line -> Vcs_git_provider.Log.parse_log_line_exn ~line)
in
let refs =
let path = Eio.Path.(Eio.Stdenv.fs env / "super-master-mind.refs") in
let contents = Eio.Path.load path in
let lines = String.split_lines contents in
Vcs_git_cli.Refs.parse_lines_exn ~lines
Vcs_git_provider.Refs.parse_lines_exn ~lines
in
let graph = Vcs.Graph.create () in
print_s [%sexp { node_count = (Vcs.Graph.node_count graph : int) }];
Expand Down
4 changes: 3 additions & 1 deletion lib/vcs/test/test__log.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ let%expect_test "parse_exn" =
let path = Eio.Path.(Eio.Stdenv.fs env / "super-master-mind.log") in
let contents = Eio.Path.load path in
let lines = String.split_lines contents in
let log = List.map lines ~f:(fun line -> Vcs_git_cli.Log.parse_log_line_exn ~line) in
let log =
List.map lines ~f:(fun line -> Vcs_git_provider.Log.parse_log_line_exn ~line)
in
let roots = Vcs.Log.roots log in
print_s [%sexp (roots : Vcs.Rev.t list)];
[%expect
Expand Down
4 changes: 2 additions & 2 deletions lib/vcs/test/test__name_status.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let%expect_test "parse_exn" =
let path = Eio.Path.(Eio.Stdenv.fs env / "super-master-mind.name-status") in
let contents = Eio.Path.load path in
let lines = String.split_lines contents in
let name_status = Vcs_git_cli.Name_status.parse_lines_exn ~lines in
let name_status = Vcs_git_provider.Name_status.parse_lines_exn ~lines in
let files_at_src = Vcs.Name_status.files_at_src name_status in
let files_at_dst = Vcs.Name_status.files_at_dst name_status in
print_s [%sexp (Set.diff files_at_dst files_at_src : Set.M(Vcs.Path_in_repo).t)];
Expand All @@ -47,7 +47,7 @@ let%expect_test "files" =
; "R100\toriginal_renamed_file\tnew_renamed_file"
]
in
let name_status = Vcs_git_cli.Name_status.parse_lines_exn ~lines in
let name_status = Vcs_git_provider.Name_status.parse_lines_exn ~lines in
print_s [%sexp (name_status : Vcs.Name_status.t)];
[%expect
{|
Expand Down
2 changes: 1 addition & 1 deletion lib/vcs/test/test__num_status.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let%expect_test "parse_exn" =
let path = Eio.Path.(Eio.Stdenv.fs env / "super-master-mind.num-status") in
let contents = Eio.Path.load path in
let lines = String.split_lines contents in
let num_status = Vcs_git_cli.Num_status.parse_lines_exn ~lines in
let num_status = Vcs_git_provider.Num_status.parse_lines_exn ~lines in
ignore (num_status : Vcs.Num_status.t);
[%expect {||}];
()
Expand Down
2 changes: 1 addition & 1 deletion lib/vcs_arg/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Or_error.Let_syntax
-open
Cmdlang)
(libraries base cmdlang eio fpath fpath-base unix vcs vcs-git)
(libraries base cmdlang eio fpath fpath-base unix vcs vcs-git-eio)
(instrumentation
(backend bisect_ppx))
(lint
Expand Down
6 changes: 3 additions & 3 deletions lib/vcs_arg/src/vcs_arg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module Create_vcs_backend = struct
| Some ((`Git as vcs), dir) ->
let vcs =
match vcs with
| `Git -> Vcs_git.create ~env
| `Git -> Vcs_git_eio.create ~env
in
let repo_root = repo_root dir in
Some (vcs, repo_root)
Expand All @@ -80,7 +80,7 @@ module Context = struct
{ config : Config.t
; fs : Eio.Fs.dir_ty Eio.Path.t
; cwd : Absolute_path.t
; vcs : Vcs_git.t'
; vcs : Vcs_git_eio.t'
; repo_root : Vcs.Repo_root.t
}

Expand Down Expand Up @@ -121,7 +121,7 @@ end

module Initialized = struct
type t =
{ vcs : Vcs_git.t'
{ vcs : Vcs_git_eio.t'
; repo_root : Vcs.Repo_root.t
; context : Context.t
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vcs_arg/src/vcs_arg.mli
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ end

module Initialized : sig
type t =
{ vcs : Vcs_git.t'
{ vcs : Vcs_git_eio.t'
; repo_root : Vcs.Repo_root.t
; context : Context.t
}
Expand Down
2 changes: 1 addition & 1 deletion lib/vcs_command/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
fpath-base
vcs
vcs-arg
vcs-git
vcs-git-eio
vcs-private-libs-eio.eio-writer)
(instrumentation
(backend bisect_ppx))
Expand Down
2 changes: 1 addition & 1 deletion lib/vcs_git_blocking/src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Base
-open
Fpath_base)
(libraries base fpath fpath-base provider unix vcs vcs-git-cli)
(libraries base fpath fpath-base provider unix vcs vcs-git-provider)
(instrumentation
(backend bisect_ppx))
(lint
Expand Down
2 changes: 1 addition & 1 deletion lib/vcs_git_blocking/src/runtime.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@

type t

include Vcs_git_cli.Runtime.S with type t := t
include Vcs_git_provider.Runtime.S with type t := t

val create : unit -> t
6 changes: 3 additions & 3 deletions lib/vcs_git_blocking/src/vcs_git_blocking.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
(*******************************************************************************)

type 'a t = ([> Vcs_git_cli.Trait.t ] as 'a) Vcs.t
type t' = Vcs_git_cli.Trait.t t
type 'a t = ([> Vcs_git_provider.Trait.t ] as 'a) Vcs.t
type t' = Vcs_git_provider.Trait.t t

module Impl = struct
include Runtime
include Vcs_git_cli.Make (Runtime)
include Vcs_git_provider.Make (Runtime)
end

let create () = Vcs.create (Provider.T { t = Impl.create (); handler = Impl.handler () })
8 changes: 4 additions & 4 deletions lib/vcs_git_blocking/src/vcs_git_blocking.mli
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
(*_******************************************************************************)

(** Implementation of a git provider for the {!module:Vcs} library, based on
[Stdlib] and {!module:Vcs_git_cli}.
[Stdlib] and {!module:Vcs_git_provider}.
This implementation is based on the [git] command line tool. We run it as an
external program with utils from [Stdlib] and [Unix], producing the right
command line invocation and parsing the output to produce a typed version of
the expected results with [Vcs_git_cli]. Note that [git] must be found in the
the expected results with [Vcs_git_provider]. Note that [git] must be found in the
PATH of the running environment. *)

type 'a t = ([> Vcs_git_cli.Trait.t ] as 'a) Vcs.t
type 'a t = ([> Vcs_git_provider.Trait.t ] as 'a) Vcs.t

(** This is a convenient type alias that may be used to designate a provider
with the exact list of traits supported by this implementation. *)
type t' = Vcs_git_cli.Trait.t t
type t' = Vcs_git_provider.Trait.t t

val create : unit -> _ t
6 changes: 3 additions & 3 deletions lib/vcs_git/src/dune → lib/vcs_git_eio/src/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(library
(name vcs_git)
(public_name vcs-git)
(name vcs_git_eio)
(public_name vcs-git-eio)
(flags
:standard
-w
Expand All @@ -21,7 +21,7 @@
fpath
fpath-base
vcs
vcs-git-cli
vcs-git-provider
vcs-private-libs-eio.eio-process)
(instrumentation
(backend bisect_ppx))
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@

type t

include Vcs_git_cli.Runtime.S with type t := t
include Vcs_git_provider.Runtime.S with type t := t

val create : env:< fs : _ Eio.Path.t ; process_mgr : _ Eio.Process.mgr ; .. > -> t
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
(* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively. *)
(*******************************************************************************)

type 'a t = ([> Vcs_git_cli.Trait.t ] as 'a) Vcs.t
type t' = Vcs_git_cli.Trait.t t
type 'a t = ([> Vcs_git_provider.Trait.t ] as 'a) Vcs.t
type t' = Vcs_git_provider.Trait.t t

module Impl = struct
include Runtime
include Vcs_git_cli.Make (Runtime)
include Vcs_git_provider.Make (Runtime)
end

let create ~env =
Expand Down
Loading

0 comments on commit 02224aa

Please sign in to comment.