diff --git a/CHANGES.md b/CHANGES.md index 8fb484d..9361520 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,17 +1,26 @@ -## 0.0.8 (unreleased) - -### Added +## 0.0.8 (2024-09-30) ### Changed -- Remove `eio-writer` dependency in `vcs-command`. - -### Deprecated +- Reduced dependencies from `fpath-base` to `fpath-sexp0` where able (#27, @mbarbin). +- Inline `eio-process` dependency into `vcs_git_eio` (#27, @mbarbin). +- Replace calls to `eio-writer` by print functions from stdlib in `vcs-command` (#26, @mbarbin). +- Refactor subgraph computation to not need union-find (#25, @mbarbin). +- Improve `Vcs.Graph` documentation (#24, @mbarbin). +- Upgrade documentation dependencies (#23, @mbarbin). +- Update documentation to use diataxis (#22, @mbarbin). ### Fixed +- Fixed stale names in headache script. + ### Removed +- No more `vendor/` libraries. +- Removed dependency to vendored `eio-process`. +- Removed dependency to vendored `eio-writer`. +- Removed dependency to vendored `union-find`. + ## 0.0.7 (2024-09-20) ### Changed diff --git a/NOTICE.md b/NOTICE.md index fca68f1..26015e7 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -16,6 +16,38 @@ This notice file contains more details, as well as document the organization of - **NOTICE.md** (this file) documents the project licensing. +## A note about Eio-process + +To spawn processes in `Eio` and collect their output we've copied some code from the [Eio_process](https://github.com/mbarbin/eio-process) project. The `Eio_process` project is released under `MIT`. + +### Notice + +The file where we make use of this code is `lib/vcs_git_eio/src/runtime.ml`. We've added a notice in the file and a comment next to the code that was copied and modified, which include `Eio_process`'s original LICENSE: + +```text +MIT License + +Copyright (c) 2023 Mathieu Barbin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + ## A note about Iron In 2016-2017, Jane Street released on GitHub an internal code review system named [Iron](https://github.com/janestreet/iron). diff --git a/dune-project b/dune-project index c46c4a9..08dec7d 100644 --- a/dune-project +++ b/dune-project @@ -80,7 +80,7 @@ (>= 1.0)) (fpath (>= 0.7.3)) - (fpath-base + (fpath-sexp0 (>= 0.2.0)) (ppx_compare (and @@ -192,7 +192,7 @@ (< v0.18))) (fpath (>= 0.7.3)) - (fpath-base + (fpath-sexp0 (>= 0.2.0)) (ppx_compare (and @@ -242,7 +242,7 @@ (>= 1.0)) (fpath (>= 0.7.3)) - (fpath-base + (fpath-sexp0 (>= 0.2.0)) (ppx_compare (and @@ -279,8 +279,6 @@ (vcs (= :version)) (vcs-git-provider - (= :version)) - (vcs-private-libs-eio (= :version)))) (package @@ -296,7 +294,7 @@ (< v0.18))) (fpath (>= 0.7.3)) - (fpath-base + (fpath-sexp0 (>= 0.2.0)) (ppx_compare (and @@ -383,6 +381,8 @@ (>= 0.7.3)) (fpath-base (>= 0.2.0)) + (fpath-sexp0 + (>= 0.2.0)) (mdx (and :with-doc @@ -454,8 +454,6 @@ (= :version)) (vcs-git-provider (= :version)) - (vcs-private-libs-eio - (= :version)) (vcs-test-helpers (= :version)) (sherlodoc @@ -463,54 +461,6 @@ :with-doc (>= 0.2))))) -(package - (name vcs-private-libs-eio) - (synopsis "Private eio libraries used by vcs -- do not use!") - (allow_empty) - (depends - (ocaml - (>= 5.2)) - (base - (and - (>= v0.17) - (< v0.18))) - (eio - (>= 1.0)) - (parsexp - (and - (>= v0.17) - (< v0.18))) - (ppx_compare - (and - (>= v0.17) - (< v0.18))) - (ppx_enumerate - (and - (>= v0.17) - (< v0.18))) - (ppx_hash - (and - (>= v0.17) - (< v0.18))) - (ppx_here - (and - (>= v0.17) - (< v0.18))) - (ppx_let - (and - (>= v0.17) - (< v0.18))) - (ppx_sexp_conv - (and - (>= v0.17) - (< v0.18))) - (ppx_sexp_value - (and - (>= v0.17) - (< v0.18))) - (ppxlib - (>= 0.33)))) - (package (name vcs-test-helpers) (synopsis "Helper library to write tests using vcs") @@ -525,7 +475,7 @@ (>= 1.0)) (fpath (>= 0.7.3)) - (fpath-base + (fpath-sexp0 (>= 0.2.0)) (ppx_compare (and diff --git a/example/dune b/example/dune index 9ff5e23..5eac14e 100644 --- a/example/dune +++ b/example/dune @@ -11,18 +11,16 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open - Expect_test_helpers_base - -open - Or_error.Let_syntax) + Expect_test_helpers_base) (libraries base eio eio_main expect_test_helpers_core.expect_test_helpers_base fpath - fpath-base + fpath-sexp0 vcs vcs_git_blocking vcs_git_eio diff --git a/example/hello_git_cli.ml b/example/hello_git_cli.ml index 77cc3e0..67f9ae7 100644 --- a/example/hello_git_cli.ml +++ b/example/hello_git_cli.ml @@ -66,7 +66,7 @@ let%expect_test "hello cli" = its output, and how to do this with the non-raising API of Vcs. *) let head_rev = Vcs.Or_error.git vcs ~repo_root ~args:[ "rev-parse"; "HEAD" ] ~f:(fun output -> - let%bind stdout = Vcs.Git.Or_error.exit0_and_stdout output in + let%bind.Or_error stdout = Vcs.Git.Or_error.exit0_and_stdout output in match Vcs.Rev.of_string (String.strip stdout) with | Ok _ as ok -> ok | Error (`Msg _) -> assert false) @@ -180,7 +180,7 @@ let%expect_test "hello cli" = ~repo_root ~args:[ "rev-parse"; "--abbrev-ref"; ref_ ] ~f:Vcs.Git.Or_error.exit0_and_stdout - >>| String.strip + |> Or_error.map ~f:String.strip in (* You may be tempted to think the setup is ok, based on the happy path behavior. *) @@ -218,7 +218,7 @@ let%expect_test "hello cli" = ~repo_root ~args:[ "rev-parse"; "--abbrev-ref"; ref_ ] ~f:Vcs.Git.Or_error.exit0_and_stdout - >>| String.strip + |> Or_error.map ~f:String.strip in (* The behavior is the same in the happy path. *) print_s [%sexp (abbrev_ref "HEAD" : string Or_error.t)]; diff --git a/headache.sh b/headache.sh index 749aa4e..4294d2c 100755 --- a/headache.sh +++ b/headache.sh @@ -9,12 +9,12 @@ dirs=( "lib/vcs_arg/test" "lib/vcs_command/src" "lib/vcs_command/test" - "lib/vcs_git/src" - "lib/vcs_git/test" "lib/vcs_git_blocking/src" "lib/vcs_git_blocking/test" - "lib/vcs_git_cli/src" - "lib/vcs_git_cli/test" + "lib/vcs_git_eio/src" + "lib/vcs_git_eio/test" + "lib/vcs_git_provider/src" + "lib/vcs_git_provider/test" "lib/vcs_test_helpers/src" "lib/vcs_test_helpers/test" "test/expect" diff --git a/lib/vcs/test/dune b/lib/vcs/test/dune index 90d68a6..e2010bd 100644 --- a/lib/vcs/test/dune +++ b/lib/vcs/test/dune @@ -16,7 +16,7 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open Expect_test_helpers_base) (libraries @@ -26,7 +26,7 @@ err expect_test_helpers_core.expect_test_helpers_base fpath - fpath-base + fpath-sexp0 vcs vcs_git_provider) (instrumentation diff --git a/lib/vcs_arg/src/dune b/lib/vcs_arg/src/dune index c9ac44b..aa34b75 100644 --- a/lib/vcs_arg/src/dune +++ b/lib/vcs_arg/src/dune @@ -10,10 +10,10 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open Cmdlang) - (libraries base cmdlang eio fpath fpath-base unix vcs vcs-git-eio) + (libraries base cmdlang eio fpath fpath-sexp0 unix vcs vcs-git-eio) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_arg/test/dune b/lib/vcs_arg/test/dune index 3510e0d..7f64be4 100644 --- a/lib/vcs_arg/test/dune +++ b/lib/vcs_arg/test/dune @@ -11,7 +11,7 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open Expect_test_helpers_base) (libraries @@ -20,7 +20,7 @@ eio_main expect_test_helpers_core.expect_test_helpers_base fpath - fpath-base + fpath-sexp0 vcs_arg) (instrumentation (backend bisect_ppx)) diff --git a/lib/vcs_git_blocking/src/dune b/lib/vcs_git_blocking/src/dune index 5bb3c34..22d6207 100644 --- a/lib/vcs_git_blocking/src/dune +++ b/lib/vcs_git_blocking/src/dune @@ -10,8 +10,8 @@ -open Base -open - Fpath_base) - (libraries base fpath fpath-base provider unix vcs vcs-git-provider) + Fpath_sexp0) + (libraries base fpath fpath-sexp0 provider unix vcs vcs-git-provider) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_git_blocking/test/dune b/lib/vcs_git_blocking/test/dune index ceafafb..3a22b64 100644 --- a/lib/vcs_git_blocking/test/dune +++ b/lib/vcs_git_blocking/test/dune @@ -11,14 +11,14 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open Expect_test_helpers_base) (libraries base expect_test_helpers_core.expect_test_helpers_base fpath - fpath-base + fpath-sexp0 vcs vcs_git_blocking) (instrumentation diff --git a/lib/vcs_git_eio/src/dune b/lib/vcs_git_eio/src/dune index ed03a3d..26f72a5 100644 --- a/lib/vcs_git_eio/src/dune +++ b/lib/vcs_git_eio/src/dune @@ -10,17 +10,8 @@ -open Base -open - Fpath_base - -open - Vcs_eio_process) - (libraries - base - eio - fpath - fpath-base - vcs - vcs-git-provider - vcs-private-libs-eio.eio-process) + Fpath_sexp0) + (libraries base eio fpath fpath-sexp0 vcs vcs-git-provider) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_git_eio/src/runtime.ml b/lib/vcs_git_eio/src/runtime.ml index 088eec0..4d0e59e 100644 --- a/lib/vcs_git_eio/src/runtime.ml +++ b/lib/vcs_git_eio/src/runtime.ml @@ -42,18 +42,135 @@ let save_file ?(perms = 0o666) t ~path ~(file_contents : Vcs.File_contents.t) = Eio.Path.save ~create:(`Or_truncate perms) path (file_contents :> string)) ;; +(* The modules [Exit_status], [Lines] and the function [git] below are derived + from the [Eio_process] project version [0.0.4] which is released under MIT + and may be found at [https://github.com/mbarbin/eio-process]. + + The changes we made to the code are: + + - We removed the ability to parse the output of the process as a sexp. We + don't expect a git process to use the sexp format for its output (stdout + and stderr alike). + + - We treat a signaled exit status as an error. + + - The [git] function was adapted from [Eio_process.run], inlining the part + specific to git directly into the new function. We expect that the [git] + function may be further specialized in the future to fit the requirement of + the project. + + See Eio_process's LICENSE below: + + ---------------------------------------------------------------------------- + + MIT License + + Copyright (c) 2023 Mathieu Barbin + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. *) + +module Exit_status = struct + [@@@coverage off] + + type t = + [ `Exited of int + | `Signaled of int + ] + [@@deriving sexp_of] +end + +module Lines = struct + type t = string list + + let sexp_of_t (t : t) = + match t with + | [] -> [%sexp ""] + | [ hd ] -> [%sexp (hd : string)] + | _ :: _ :: _ as lines -> [%sexp (lines : string list)] + ;; + + let create string : t = String.split_lines string +end + +exception User_error of Error.t + let git ?env t ~cwd ~args ~f = - Eio_process.run - ~process_mgr:t.process_mgr - ~cwd:Eio.Path.(t.fs / Absolute_path.to_string cwd) - ?env - ~prog:"git" - ~args - () - ~f:(fun { Eio_process.Output.stdout; stderr; exit_status } -> - match exit_status with - | `Exited exit_code -> f { Vcs.Git.Output.exit_code; stdout; stderr } - | `Signaled signal -> - Or_error.error_s - [%sexp "process exited abnormally", { signal : int }] [@coverage off]) + let cwd = Eio.Path.(t.fs / Absolute_path.to_string cwd) in + let prog = "git" in + Eio.Switch.run + @@ fun sw -> + let r, w = Eio.Process.pipe t.process_mgr ~sw in + let re, we = Eio.Process.pipe t.process_mgr ~sw in + let exit_status_r : [ Exit_status.t | `Unknown ] ref = ref `Unknown in + let stdout_r = ref "" in + let stderr_r = ref "" in + try + let child = + Eio.Process.spawn + ~sw + t.process_mgr + ~cwd + ?stdin:None + ~stdout:w + ~stderr:we + ?env + ?executable:None + (prog :: args) + in + Eio.Flow.close w; + Eio.Flow.close we; + let stdout = Eio.Buf_read.parse_exn Eio.Buf_read.take_all r ~max_size:Int.max_value in + stdout_r := stdout; + let stderr = + Eio.Buf_read.parse_exn Eio.Buf_read.take_all re ~max_size:Int.max_value + in + stderr_r := stderr; + Eio.Flow.close r; + let exit_status = Eio.Process.await child in + exit_status_r := (exit_status :> [ Exit_status.t | `Unknown ]); + match exit_status with + | `Signaled signal -> + raise + (User_error + (Error.create_s + [%sexp "process exited abnormally", { signal : int }] [@coverage off])) + [@coverage off] + | `Exited exit_code -> + (match f { Vcs.Git.Output.exit_code; stdout; stderr } with + | Ok _ as ok -> ok + | Error err -> raise (User_error err)) + with + | (Eio.Exn.Io _ | User_error _) as exn -> + let error = + match exn with + | Eio.Exn.Io _ -> Error.of_exn exn + | User_error error -> error + | _ -> assert false + in + Or_error.error_s + [%sexp + { prog : string + ; args : string list + ; exit_status = (!exit_status_r : [ Exit_status.t | `Unknown ]) + ; cwd = (snd cwd : string) + ; stdout = (Lines.create !stdout_r : Lines.t) + ; stderr = (Lines.create !stderr_r : Lines.t) + ; error : Error.t + }] ;; diff --git a/lib/vcs_git_eio/test/dune b/lib/vcs_git_eio/test/dune index 6e490d3..d7c4cda 100644 --- a/lib/vcs_git_eio/test/dune +++ b/lib/vcs_git_eio/test/dune @@ -11,7 +11,7 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open Expect_test_helpers_base) (libraries @@ -20,7 +20,7 @@ eio_main expect_test_helpers_core.expect_test_helpers_base fpath - fpath-base + fpath-sexp0 vcs vcs_git_eio vcs_test_helpers) diff --git a/lib/vcs_git_provider/src/dune b/lib/vcs_git_provider/src/dune index de7675b..afbe23e 100644 --- a/lib/vcs_git_provider/src/dune +++ b/lib/vcs_git_provider/src/dune @@ -10,10 +10,10 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open Or_error.Let_syntax) - (libraries base fpath fpath-base vcs) + (libraries base fpath fpath-sexp0 vcs) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_test_helpers/src/dune b/lib/vcs_test_helpers/src/dune index 919bbec..e3b56b9 100644 --- a/lib/vcs_test_helpers/src/dune +++ b/lib/vcs_test_helpers/src/dune @@ -10,8 +10,8 @@ -open Base -open - Fpath_base) - (libraries base eio fpath fpath-base unix vcs) + Fpath_sexp0) + (libraries base eio fpath fpath-sexp0 unix vcs) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_test_helpers/test/dune b/lib/vcs_test_helpers/test/dune index 248e153..dfa8cff 100644 --- a/lib/vcs_test_helpers/test/dune +++ b/lib/vcs_test_helpers/test/dune @@ -11,7 +11,7 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open Expect_test_helpers_base) (libraries @@ -20,7 +20,7 @@ eio_main expect_test_helpers_core.expect_test_helpers_base fpath - fpath-base + fpath-sexp0 vcs vcs_git_eio vcs_test_helpers) diff --git a/test/expect/dune b/test/expect/dune index 895f531..9a34872 100644 --- a/test/expect/dune +++ b/test/expect/dune @@ -11,7 +11,7 @@ -open Base -open - Fpath_base + Fpath_sexp0 -open Expect_test_helpers_base) (libraries @@ -20,7 +20,7 @@ eio_main expect_test_helpers_core.expect_test_helpers_base fpath - fpath-base + fpath-sexp0 vcs vcs_git_blocking vcs_git_eio diff --git a/test/expect/nonraising_unit_tests.ml b/test/expect/nonraising_unit_tests.ml index bd2c209..8b96562 100644 --- a/test/expect/nonraising_unit_tests.ml +++ b/test/expect/nonraising_unit_tests.ml @@ -79,7 +79,7 @@ let%expect_test "num stat without lines" = (exit_status (Exited 128)) (cwd ) (stdout "") - (stderr ("fatal: pathspec 'unknown-file.txt' did not match any files")) + (stderr "fatal: pathspec 'unknown-file.txt' did not match any files") (error "expected exit code 0")))) |}]; let () = diff --git a/vcs-arg.opam b/vcs-arg.opam index 97ef92b..f5a2a08 100644 --- a/vcs-arg.opam +++ b/vcs-arg.opam @@ -14,7 +14,7 @@ depends: [ "cmdlang" {>= "0.0.5"} "eio" {>= "1.0"} "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"} diff --git a/vcs-git-blocking.opam b/vcs-git-blocking.opam index 7cc0f0c..d167f0e 100644 --- a/vcs-git-blocking.opam +++ b/vcs-git-blocking.opam @@ -13,7 +13,7 @@ depends: [ "ocaml" {>= "5.2"} "base" {>= "v0.17" & < "v0.18"} "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"} diff --git a/vcs-git-eio.opam b/vcs-git-eio.opam index 9a961d0..11c14b4 100644 --- a/vcs-git-eio.opam +++ b/vcs-git-eio.opam @@ -13,7 +13,7 @@ depends: [ "base" {>= "v0.17" & < "v0.18"} "eio" {>= "1.0"} "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"} @@ -25,7 +25,6 @@ depends: [ "provider" {>= "0.0.8"} "vcs" {= version} "vcs-git-provider" {= version} - "vcs-private-libs-eio" {= version} "odoc" {with-doc} ] build: [ diff --git a/vcs-git-provider.opam b/vcs-git-provider.opam index f2d1a1c..1248ed2 100644 --- a/vcs-git-provider.opam +++ b/vcs-git-provider.opam @@ -12,7 +12,7 @@ depends: [ "ocaml" {>= "5.2"} "base" {>= "v0.17" & < "v0.18"} "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"} diff --git a/vcs-private-libs-eio.opam b/vcs-private-libs-eio.opam deleted file mode 100644 index 63093b4..0000000 --- a/vcs-private-libs-eio.opam +++ /dev/null @@ -1,40 +0,0 @@ -# This file is generated by dune, edit dune-project instead -opam-version: "2.0" -synopsis: "Private eio libraries used by vcs -- do not use!" -maintainer: ["Mathieu Barbin "] -authors: ["Mathieu Barbin"] -license: "LGPL-3.0-or-later WITH LGPL-3.0-linking-exception" -homepage: "https://github.com/mbarbin/vcs" -doc: "https://mbarbin.github.io/vcs/" -bug-reports: "https://github.com/mbarbin/vcs/issues" -depends: [ - "dune" {>= "3.16"} - "ocaml" {>= "5.2"} - "base" {>= "v0.17" & < "v0.18"} - "eio" {>= "1.0"} - "parsexp" {>= "v0.17" & < "v0.18"} - "ppx_compare" {>= "v0.17" & < "v0.18"} - "ppx_enumerate" {>= "v0.17" & < "v0.18"} - "ppx_hash" {>= "v0.17" & < "v0.18"} - "ppx_here" {>= "v0.17" & < "v0.18"} - "ppx_let" {>= "v0.17" & < "v0.18"} - "ppx_sexp_conv" {>= "v0.17" & < "v0.18"} - "ppx_sexp_value" {>= "v0.17" & < "v0.18"} - "ppxlib" {>= "0.33"} - "odoc" {with-doc} -] -build: [ - ["dune" "subst"] {dev} - [ - "dune" - "build" - "-p" - name - "-j" - jobs - "@install" - "@runtest" {with-test} - "@doc" {with-doc} - ] -] -dev-repo: "git+https://github.com/mbarbin/vcs.git" diff --git a/vcs-test-helpers.opam b/vcs-test-helpers.opam index e349d07..086ff2d 100644 --- a/vcs-test-helpers.opam +++ b/vcs-test-helpers.opam @@ -13,7 +13,7 @@ depends: [ "base" {>= "v0.17" & < "v0.18"} "eio" {>= "1.0"} "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"} diff --git a/vcs-tests.opam b/vcs-tests.opam index 1a040ed..3a25b75 100644 --- a/vcs-tests.opam +++ b/vcs-tests.opam @@ -25,6 +25,7 @@ depends: [ "expect_test_helpers_core" {>= "v0.17" & < "v0.18"} "fpath" {>= "0.7.3"} "fpath-base" {>= "0.2.0"} + "fpath-sexp0" {>= "0.2.0"} "mdx" {with-doc & >= "2.4"} "ppx_compare" {>= "v0.17" & < "v0.18"} "ppx_enumerate" {>= "v0.17" & < "v0.18"} @@ -47,7 +48,6 @@ depends: [ "vcs-git-blocking" {= version} "vcs-git-eio" {= version} "vcs-git-provider" {= version} - "vcs-private-libs-eio" {= version} "vcs-test-helpers" {= version} "sherlodoc" {with-doc & >= "0.2"} "odoc" {with-doc} diff --git a/vendor/dune b/vendor/dune deleted file mode 100644 index 806de80..0000000 --- a/vendor/dune +++ /dev/null @@ -1 +0,0 @@ -(vendored_dirs *) diff --git a/vendor/eio-process/LICENSE b/vendor/eio-process/LICENSE deleted file mode 100644 index 21e7be4..0000000 --- a/vendor/eio-process/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Mathieu Barbin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/eio-process/LICENSE.eio b/vendor/eio-process/LICENSE.eio deleted file mode 100644 index 991e2f5..0000000 --- a/vendor/eio-process/LICENSE.eio +++ /dev/null @@ -1,18 +0,0 @@ -This project extends the module `Eio.Process` from the -[eio](https://github.com/ocaml-multicore/eio) project, which has the -following license: - -Copyright (C) 2021 Anil Madhavapeddy -Copyright (C) 2022 Thomas Leonard - -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. diff --git a/vendor/eio-process/LICENSE.janestreet b/vendor/eio-process/LICENSE.janestreet deleted file mode 100644 index d592744..0000000 --- a/vendor/eio-process/LICENSE.janestreet +++ /dev/null @@ -1,25 +0,0 @@ -This project took inspiration from the `Async_unix.Process` module, -from the [async_unix](https://github.com/janestreet/async_unix) -project, which has the following license: - -The MIT License - -Copyright (c) 2008--2023 Jane Street Group, LLC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/eio-process/src/dune b/vendor/eio-process/src/dune deleted file mode 100644 index 1315202..0000000 --- a/vendor/eio-process/src/dune +++ /dev/null @@ -1,23 +0,0 @@ -(library - (name vcs_eio_process) - (public_name vcs-private-libs-eio.eio-process) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Or_error.Let_syntax) - (libraries base eio parsexp) - (preprocess - (pps - ppx_compare - ppx_enumerate - ppx_hash - ppx_here - ppx_let - ppx_sexp_conv - ppx_sexp_value))) diff --git a/vendor/eio-process/src/eio_process.ml b/vendor/eio-process/src/eio_process.ml deleted file mode 100644 index a35f15c..0000000 --- a/vendor/eio-process/src/eio_process.ml +++ /dev/null @@ -1,147 +0,0 @@ -module Exit_status = struct - [@@@coverage off] - - type t = - [ `Exited of int - | `Signaled of int - ] - [@@deriving sexp_of] -end - -module Lines_or_sexp = struct - type t = - | Lines of string list - | Sexp of Sexp.t - - let sexp_of_t t = - match t with - | Lines [] -> [%sexp ""] - | Lines lines -> [%sexp (lines : string list)] - | Sexp sexp -> sexp - ;; - - let create string = - try Sexp (Parsexp.Conv_single.parse_string_exn string Fn.id) with - | _ -> Lines (String.split_lines string) - ;; -end - -module Output = struct - type t = - { stdout : string - ; stderr : string - ; exit_status : Exit_status.t - } - - let sexp_of_t { stdout; stderr; exit_status } = - [%sexp - { stdout = (Lines_or_sexp.create stdout : Lines_or_sexp.t) - ; stderr = (Lines_or_sexp.create stderr : Lines_or_sexp.t) - ; exit_status : Exit_status.t - }] - ;; - - let exited t ~accept_exit_codes = - match - match t.exit_status with - | `Exited code -> List.Assoc.find accept_exit_codes ~equal:Int.equal code - | `Signaled _ -> None - with - | Some a -> Ok a - | None -> - Or_error.error_s - [%sexp - "unexpected exit status" - , { accept_exit_codes = (List.map accept_exit_codes ~f:fst : int list) }] - ;; - - let exit ?(accept_nonzero_exit = []) t = - exited - t - ~accept_exit_codes: - ((0, ()) :: List.map accept_nonzero_exit ~f:(fun code -> code, ())) - ;; - - let exit_and_stdout ?accept_nonzero_exit t = - let%map () = exit t ?accept_nonzero_exit in - t.stdout - ;; - - let expect_no_output ?(accept_nonzero_exit = []) t = - let%bind stdout = exit_and_stdout t ~accept_nonzero_exit in - if String.is_empty stdout then Ok () else Or_error.error_string "expected no output" - ;; -end - -exception User_error of Error.t - -let run ~process_mgr ~cwd ?stdin ?env ~prog ~args () ~f = - Eio.Switch.run - @@ fun sw -> - let r, w = Eio.Process.pipe process_mgr ~sw in - let re, we = Eio.Process.pipe process_mgr ~sw in - let exit_status_r : [ Exit_status.t | `Unknown ] ref = ref `Unknown in - let stdout_r = ref "" in - let stderr_r = ref "" in - try - let child = - Eio.Process.spawn - ~sw - process_mgr - ~cwd - ?stdin - ~stdout:w - ~stderr:we - ?env - ?executable:None - (prog :: args) - in - Eio.Flow.close w; - Eio.Flow.close we; - let stdout = Eio.Buf_read.parse_exn Eio.Buf_read.take_all r ~max_size:Int.max_value in - stdout_r := stdout; - let stderr = - Eio.Buf_read.parse_exn Eio.Buf_read.take_all re ~max_size:Int.max_value - in - stderr_r := stderr; - Eio.Flow.close r; - let exit_status = Eio.Process.await child in - exit_status_r := (exit_status :> [ Exit_status.t | `Unknown ]); - match f { Output.stdout; stderr; exit_status } with - | Ok _ as ok -> ok - | Error err -> raise (User_error err) - with - | (Eio.Exn.Io _ | User_error _) as exn -> - let error = - match exn with - | Eio.Exn.Io _ -> Error.of_exn exn - | User_error error -> error - | _ -> assert false - in - Or_error.error_s - [%sexp - { prog : string - ; args : string list - ; exit_status = (!exit_status_r : [ Exit_status.t | `Unknown ]) - ; cwd = (snd cwd : string) - ; stdout = (Lines_or_sexp.create !stdout_r : Lines_or_sexp.t) - ; stderr = (Lines_or_sexp.create !stderr_r : Lines_or_sexp.t) - ; error : Error.t - }] -;; - -let run_stdout ~process_mgr ~cwd ?stdin ?accept_nonzero_exit ?env ~prog ~args () = - run ~process_mgr ~cwd ?stdin ?env ~prog ~args () ~f:(fun output -> - Output.exit_and_stdout output ?accept_nonzero_exit) -;; - -let run_lines ~process_mgr ~cwd ?stdin ?accept_nonzero_exit ?env ~prog ~args () = - run ~process_mgr ~cwd ?stdin ?env ~prog ~args () ~f:(fun output -> - Output.exit_and_stdout output ?accept_nonzero_exit >>| String.split_lines) -;; - -let run_expect_no_output ~process_mgr ~cwd ?stdin ?accept_nonzero_exit ?env ~prog ~args () - = - run ~process_mgr ~cwd ?stdin ?env ~prog ~args () ~f:(fun output -> - Output.expect_no_output output ?accept_nonzero_exit) -;; diff --git a/vendor/eio-process/src/eio_process.mli b/vendor/eio-process/src/eio_process.mli deleted file mode 100644 index b2ac908..0000000 --- a/vendor/eio-process/src/eio_process.mli +++ /dev/null @@ -1,68 +0,0 @@ -(** Spawn external processes in [Eio] with convenient wrappers inspired by - [Async_unix.Process]. *) - -module Exit_status : sig - type t = - [ `Exited of int - | `Signaled of int - ] - [@@deriving sexp_of] -end - -module Output : sig - type t = - { stdout : string - ; stderr : string - ; exit_status : Exit_status.t - } - [@@deriving sexp_of] - - val exit : ?accept_nonzero_exit:int list -> t -> unit Or_error.t - val exit_and_stdout : ?accept_nonzero_exit:int list -> t -> string Or_error.t - val exited : t -> accept_exit_codes:(int * 'a) list -> 'a Or_error.t - val expect_no_output : ?accept_nonzero_exit:int list -> t -> unit Or_error.t -end - -val run - : process_mgr:_ Eio.Process.mgr - -> cwd:Eio.Fs.dir_ty Eio.Path.t - -> ?stdin:_ Eio.Flow.source - -> ?env:string array - -> prog:string - -> args:string list - -> unit - -> f:(Output.t -> 'a Or_error.t) - -> 'a Or_error.t - -val run_stdout - : process_mgr:_ Eio.Process.mgr - -> cwd:Eio.Fs.dir_ty Eio.Path.t - -> ?stdin:_ Eio.Flow.source - -> ?accept_nonzero_exit:int list - -> ?env:string array - -> prog:string - -> args:string list - -> unit - -> string Or_error.t - -val run_lines - : process_mgr:_ Eio.Process.mgr - -> cwd:Eio.Fs.dir_ty Eio.Path.t - -> ?stdin:_ Eio.Flow.source - -> ?accept_nonzero_exit:int list - -> ?env:string array - -> prog:string - -> args:string list - -> unit - -> string list Or_error.t - -val run_expect_no_output - : process_mgr:_ Eio.Process.mgr - -> cwd:Eio.Fs.dir_ty Eio.Path.t - -> ?stdin:_ Eio.Flow.source - -> ?accept_nonzero_exit:int list - -> ?env:string array - -> prog:string - -> args:string list - -> unit - -> unit Or_error.t diff --git a/vendor/eio-process/src/vcs_eio_process.ml b/vendor/eio-process/src/vcs_eio_process.ml deleted file mode 100644 index b6e570f..0000000 --- a/vendor/eio-process/src/vcs_eio_process.ml +++ /dev/null @@ -1,3 +0,0 @@ -(* We use ["vcs_eio_process.cmxa"] as library name to limit the potential module - name conflicts for projects linking with both [vcs] and [eio_process]. *) -module Eio_process = Eio_process diff --git a/vendor/update-eio-process.sh b/vendor/update-eio-process.sh deleted file mode 100755 index 471b32a..0000000 --- a/vendor/update-eio-process.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -version=8e19e6b216fff5329f2e34c40a185f577d789c3f - -set -e -o pipefail - -TMP="$(mktemp -d)" -trap "rm -rf $TMP" EXIT - -rm -rf eio-process -mkdir -p eio-process/src - -( - cd $TMP - git clone https://github.com/mbarbin/eio-process.git - cd eio-process - git checkout $version -) - -SRC=$TMP/eio-process - -cp -v $SRC/LICENSE{,.janestreet,.eio} eio-process/ -cp -v -R $SRC/src eio-process/ - -git checkout eio-process/src/dune -git checkout eio-process/src/vcs_eio_process.ml -git add -A .