From 3895fee787b746ec42bef2d21040c856e3c6c671 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Tue, 15 Oct 2024 13:43:55 +0200 Subject: [PATCH] Upgrade to fpath-base 0.2.2 (rename Fpart to Fsegment) --- dune-project | 16 ++++++++-------- lib/vcs/src/trait_file_system.mli | 2 +- lib/vcs/src/vcs.mli | 6 +++--- lib/vcs/src/vcs0.ml | 6 ++++-- lib/vcs/src/vcs_interface.mli | 6 +++--- lib/vcs_command/src/vcs_command.ml | 10 +++++----- lib/vcs_git_blocking/src/runtime.ml | 2 +- lib/vcs_git_blocking/test/test__file_system.ml | 10 +++++----- lib/vcs_git_blocking/test/test__hello_commit.ml | 6 +++--- lib/vcs_git_eio/src/runtime.ml | 2 +- lib/vcs_git_eio/test/test__file_system.ml | 10 +++++----- test/expect/find_enclosing_repo_root.ml | 16 ++++++++-------- vcs-command.opam | 2 +- vcs-git-blocking.opam | 2 +- vcs-git-eio.opam | 2 +- vcs-git-provider.opam | 2 +- vcs-test-helpers.opam | 2 +- vcs-tests.opam | 4 ++-- vcs.opam | 2 +- 19 files changed, 55 insertions(+), 53 deletions(-) diff --git a/dune-project b/dune-project index dbee43d..60acefa 100644 --- a/dune-project +++ b/dune-project @@ -30,7 +30,7 @@ (fpath (>= 0.7.3)) (fpath-base - (>= 0.2.0)) + (>= 0.2.2)) (ppx_compare (and (>= v0.17) @@ -89,7 +89,7 @@ (fpath (>= 0.7.3)) (fpath-sexp0 - (>= 0.2.0)) + (>= 0.2.2)) (ppx_compare (and (>= v0.17) @@ -138,7 +138,7 @@ (fpath (>= 0.7.3)) (fpath-sexp0 - (>= 0.2.0)) + (>= 0.2.2)) (ppx_compare (and (>= v0.17) @@ -188,7 +188,7 @@ (fpath (>= 0.7.3)) (fpath-sexp0 - (>= 0.2.0)) + (>= 0.2.2)) (ppx_compare (and (>= v0.17) @@ -240,7 +240,7 @@ (fpath (>= 0.7.3)) (fpath-sexp0 - (>= 0.2.0)) + (>= 0.2.2)) (ppx_compare (and (>= v0.17) @@ -325,9 +325,9 @@ (fpath (>= 0.7.3)) (fpath-base - (>= 0.2.0)) + (>= 0.2.2)) (fpath-sexp0 - (>= 0.2.0)) + (>= 0.2.2)) (mdx (and :with-doc @@ -419,7 +419,7 @@ (fpath (>= 0.7.3)) (fpath-sexp0 - (>= 0.2.0)) + (>= 0.2.2)) (ppx_compare (and (>= v0.17) diff --git a/lib/vcs/src/trait_file_system.mli b/lib/vcs/src/trait_file_system.mli index a6e38ae..7183ade 100644 --- a/lib/vcs/src/trait_file_system.mli +++ b/lib/vcs/src/trait_file_system.mli @@ -47,5 +47,5 @@ module type S = sig according to [String.compare]. This must error out if [dir] is not a directory, or if we don't have access to it. The unix entries "." and ".." shall not be included in the result. *) - val read_dir : t -> dir:Absolute_path.t -> Fpart.t list Or_error.t + val read_dir : t -> dir:Absolute_path.t -> Fsegment.t list Or_error.t end diff --git a/lib/vcs/src/vcs.mli b/lib/vcs/src/vcs.mli index 4ad25c6..8d8ee8a 100644 --- a/lib/vcs/src/vcs.mli +++ b/lib/vcs/src/vcs.mli @@ -110,8 +110,8 @@ val init : [> Trait.init ] t -> path:Absolute_path.t -> Repo_root.t val find_enclosing_repo_root : [> Trait.file_system ] t -> from:Absolute_path.t - -> store:Fpart.t list - -> ([ `Store of Fpart.t ] * Repo_root.t) option + -> store:Fsegment.t list + -> ([ `Store of Fsegment.t ] * Repo_root.t) option (** [find_enclosing_git_repo_root vcs ~from:dir] is a convenient wrapper around {!val:find_enclosing_repo_root} for Git repositories. This is looking for @@ -179,7 +179,7 @@ val save_file (** Returns the entries of the supplied directory, ordered increasingly according to [String.compare]. The result does not include the unix entries ".", "..". *) -val read_dir : [> Trait.file_system ] t -> dir:Absolute_path.t -> Fpart.t list +val read_dir : [> Trait.file_system ] t -> dir:Absolute_path.t -> Fsegment.t list (** {1 Branches & Tags} *) diff --git a/lib/vcs/src/vcs0.ml b/lib/vcs/src/vcs0.ml index bcead1d..044f88d 100644 --- a/lib/vcs/src/vcs0.ml +++ b/lib/vcs/src/vcs0.ml @@ -63,7 +63,9 @@ let init (Provider.T { t; handler }) ~path = let find_enclosing_repo_root t ~from ~store = let rec visit dir = let entries = read_dir t ~dir in - match List.find entries ~f:(fun entry -> List.mem store entry ~equal:Fpart.equal) with + match + List.find entries ~f:(fun entry -> List.mem store entry ~equal:Fsegment.equal) + with | Some entry -> let dir = Fpath.rem_empty_seg (dir :> Fpath.t) @@ -80,7 +82,7 @@ let find_enclosing_repo_root t ~from ~store = ;; let find_enclosing_git_repo_root t ~from = - match find_enclosing_repo_root t ~from ~store:[ Fpart.dot_git ] with + match find_enclosing_repo_root t ~from ~store:[ Fsegment.dot_git ] with | None -> None | Some (_, repo_root) -> Some repo_root ;; diff --git a/lib/vcs/src/vcs_interface.mli b/lib/vcs/src/vcs_interface.mli index c55778f..4963172 100644 --- a/lib/vcs/src/vcs_interface.mli +++ b/lib/vcs/src/vcs_interface.mli @@ -64,8 +64,8 @@ module type S = sig val find_enclosing_repo_root : [> Trait.file_system ] t -> from:Absolute_path.t - -> store:Fpart.t list - -> ([ `Store of Fpart.t ] * Repo_root.t) option result + -> store:Fsegment.t list + -> ([ `Store of Fsegment.t ] * Repo_root.t) option result val add : [> Trait.add ] t @@ -111,7 +111,7 @@ module type S = sig -> file_contents:File_contents.t -> unit result - val read_dir : [> Trait.file_system ] t -> dir:Absolute_path.t -> Fpart.t list result + val read_dir : [> Trait.file_system ] t -> dir:Absolute_path.t -> Fsegment.t list result val rename_current_branch : [> Trait.branch ] t diff --git a/lib/vcs_command/src/vcs_command.ml b/lib/vcs_command/src/vcs_command.ml index 1549026..578d108 100644 --- a/lib/vcs_command/src/vcs_command.ml +++ b/lib/vcs_command/src/vcs_command.ml @@ -34,7 +34,7 @@ module Initialized = struct end let find_enclosing_repo_root vcs ~from = - match Vcs.find_enclosing_repo_root vcs ~from ~store:[ Fpart.dot_git ] with + match Vcs.find_enclosing_repo_root vcs ~from ~store:[ Fsegment.dot_git ] with | Some (`Store _, repo_root) -> repo_root | None -> Vcs.raise_s @@ -130,9 +130,9 @@ let find_enclosing_repo_root_cmd = and store = Arg.named_opt [ "store" ] - (Param.comma_separated (Param.validated_string (module Fpart))) + (Param.comma_separated (Param.validated_string (module Fsegment))) ~doc:"stop the search if one of these entries is found (e.g. '.hg')" - >>| Option.value ~default:[ Fpart.dot_git ] + >>| Option.value ~default:[ Fsegment.dot_git ] in Eio_main.run @@ fun env -> @@ -147,7 +147,7 @@ let find_enclosing_repo_root_cmd = | Some (`Store store, repo_root) -> Stdlib.Printf.printf "%s: %s\n" - (Fpart.to_string store) + (Fsegment.to_string store) (Vcs.Repo_root.to_string repo_root)) ;; @@ -307,7 +307,7 @@ let read_dir_cmd = let { Initialized.vcs; repo_root = _; cwd } = initialize ~env in let dir = Absolute_path.relativize ~root:cwd dir in let entries = Vcs.read_dir vcs ~dir in - print_sexp [%sexp (entries : Fpart.t list)]; + print_sexp [%sexp (entries : Fsegment.t list)]; ()) ;; diff --git a/lib/vcs_git_blocking/src/runtime.ml b/lib/vcs_git_blocking/src/runtime.ml index 1d9db1f..bf5e0cc 100644 --- a/lib/vcs_git_blocking/src/runtime.ml +++ b/lib/vcs_git_blocking/src/runtime.ml @@ -48,7 +48,7 @@ let read_dir () ~dir = Or_error.try_with (fun () -> let entries = Stdlib.Sys.readdir (Absolute_path.to_string dir) in Array.sort entries ~compare:String.compare; - entries |> Array.map ~f:Fpart.v |> Array.to_list) + entries |> Array.map ~f:Fsegment.v |> Array.to_list) ;; let with_cwd ~cwd ~f = diff --git a/lib/vcs_git_blocking/test/test__file_system.ml b/lib/vcs_git_blocking/test/test__file_system.ml index 6f46fd8..9bd3b51 100644 --- a/lib/vcs_git_blocking/test/test__file_system.ml +++ b/lib/vcs_git_blocking/test/test__file_system.ml @@ -21,13 +21,13 @@ let%expect_test "read_dir" = let vcs = Vcs_git_blocking.create () in - let read_dir dir = print_s [%sexp (Vcs.read_dir vcs ~dir : Fpart.t list)] in + let read_dir dir = print_s [%sexp (Vcs.read_dir vcs ~dir : Fsegment.t list)] in let cwd = Unix.getcwd () in let dir = Stdlib.Filename.temp_dir ~temp_dir:cwd "vcs_test" "" |> Absolute_path.v in let save_file file file_contents = Vcs.save_file vcs - ~path:(Absolute_path.extend dir (Fpart.v file)) + ~path:(Absolute_path.extend dir (Fsegment.v file)) ~file_contents:(Vcs.File_contents.create file_contents) in read_dir dir; @@ -45,7 +45,7 @@ let%expect_test "read_dir" = let () = (* [Vcs.read_dir] errors out on non-existing directories. *) match Vcs.read_dir vcs ~dir:(Absolute_path.v "/non-existing") with - | (_ : Fpart.t list) -> assert false + | (_ : Fsegment.t list) -> assert false | exception Vcs.E err -> print_s (Vcs_test_helpers.redact_sexp (Vcs.Err.sexp_of_t err) ~fields:[ "dir" ]) in @@ -57,13 +57,13 @@ let%expect_test "read_dir" = let () = (* [Vcs.read_dir] errors out when called on an existing file rather than a directory. *) - let path = Absolute_path.extend dir (Fpart.v "foo") in + let path = Absolute_path.extend dir (Fsegment.v "foo") in let file_exists = Stdlib.Sys.file_exists (Absolute_path.to_string path) in assert file_exists; print_s [%sexp { file_exists : bool }]; [%expect {| ((file_exists true)) |}]; match Vcs.read_dir vcs ~dir:path with - | (_ : Fpart.t list) -> assert false + | (_ : Fsegment.t list) -> assert false | exception Vcs.E err -> print_s (Vcs_test_helpers.redact_sexp (Vcs.Err.sexp_of_t err) ~fields:[ "dir"; "error" ]) diff --git a/lib/vcs_git_blocking/test/test__hello_commit.ml b/lib/vcs_git_blocking/test/test__hello_commit.ml index 71c2f52..80f4185 100644 --- a/lib/vcs_git_blocking/test/test__hello_commit.ml +++ b/lib/vcs_git_blocking/test/test__hello_commit.ml @@ -63,13 +63,13 @@ let%expect_test "hello commit" = let%expect_test "read_dir" = let vcs = Vcs_git_blocking.create () in - let read_dir dir = print_s [%sexp (Vcs.read_dir vcs ~dir : Fpart.t list)] in + let read_dir dir = print_s [%sexp (Vcs.read_dir vcs ~dir : Fsegment.t list)] in let cwd = Unix.getcwd () in let dir = Stdlib.Filename.temp_dir ~temp_dir:cwd "vcs_test" "" |> Absolute_path.v in let save_file file file_contents = Vcs.save_file vcs - ~path:(Absolute_path.extend dir (Fpart.v file)) + ~path:(Absolute_path.extend dir (Fsegment.v file)) ~file_contents:(Vcs.File_contents.create file_contents) in read_dir dir; @@ -84,7 +84,7 @@ let%expect_test "read_dir" = [%expect {| (foo hello.txt) |}]; let () = match Vcs.read_dir vcs ~dir:(Absolute_path.v "/invalid") with - | (_ : Fpart.t list) -> assert false + | (_ : Fsegment.t list) -> assert false | exception Vcs.E err -> print_s [%sexp (err : Vcs.Err.t)] in [%expect diff --git a/lib/vcs_git_eio/src/runtime.ml b/lib/vcs_git_eio/src/runtime.ml index ba737ce..958a05f 100644 --- a/lib/vcs_git_eio/src/runtime.ml +++ b/lib/vcs_git_eio/src/runtime.ml @@ -44,7 +44,7 @@ let save_file ?(perms = 0o666) t ~path ~(file_contents : Vcs.File_contents.t) = let read_dir t ~dir = let dir = Eio.Path.(t.fs / Absolute_path.to_string dir) in - Or_error.try_with (fun () -> Eio.Path.read_dir dir |> List.map ~f:Fpart.v) + Or_error.try_with (fun () -> Eio.Path.read_dir dir |> List.map ~f:Fsegment.v) ;; (* The modules [Exit_status], [Lines] and the function [git] below are derived diff --git a/lib/vcs_git_eio/test/test__file_system.ml b/lib/vcs_git_eio/test/test__file_system.ml index 8299c6f..626c2d3 100644 --- a/lib/vcs_git_eio/test/test__file_system.ml +++ b/lib/vcs_git_eio/test/test__file_system.ml @@ -27,11 +27,11 @@ let%expect_test "read_dir" = let vcs = Vcs_git_eio.create ~env in let repo_root = Vcs_test_helpers.init_temp_repo ~env ~sw ~vcs in let dir = Vcs.Repo_root.to_absolute_path repo_root in - let read_dir dir = print_s [%sexp (Vcs.read_dir vcs ~dir : Fpart.t list)] in + let read_dir dir = print_s [%sexp (Vcs.read_dir vcs ~dir : Fsegment.t list)] in let save_file file file_contents = Vcs.save_file vcs - ~path:(Absolute_path.extend dir (Fpart.v file)) + ~path:(Absolute_path.extend dir (Fsegment.v file)) ~file_contents:(Vcs.File_contents.create file_contents) in read_dir dir; @@ -50,7 +50,7 @@ let%expect_test "read_dir" = let () = (* [Vcs.read_dir] errors out on non-existing directories. *) match Vcs.read_dir vcs ~dir:(Absolute_path.v "/non-existing") with - | (_ : Fpart.t list) -> assert false + | (_ : Fsegment.t list) -> assert false | exception Vcs.E err -> print_s (Vcs_test_helpers.redact_sexp (Vcs.Err.sexp_of_t err) ~fields:[ "dir"; "error" ]) @@ -59,13 +59,13 @@ let%expect_test "read_dir" = let () = (* [Vcs.read_dir] errors out when called on an existing file rather than a directory. *) - let path = Absolute_path.extend dir (Fpart.v "foo") in + let path = Absolute_path.extend dir (Fsegment.v "foo") in let file_exists = Stdlib.Sys.file_exists (Absolute_path.to_string path) in assert file_exists; print_s [%sexp { file_exists : bool }]; [%expect {| ((file_exists true)) |}]; match Vcs.read_dir vcs ~dir:path with - | (_ : Fpart.t list) -> assert false + | (_ : Fsegment.t list) -> assert false | exception Vcs.E err -> print_s (Vcs_test_helpers.redact_sexp (Vcs.Err.sexp_of_t err) ~fields:[ "dir"; "error" ]) diff --git a/test/expect/find_enclosing_repo_root.ml b/test/expect/find_enclosing_repo_root.ml index 818b93e..c82561e 100644 --- a/test/expect/find_enclosing_repo_root.ml +++ b/test/expect/find_enclosing_repo_root.ml @@ -29,11 +29,11 @@ let%expect_test "find_enclosing_repo_root" = (* read_dir *) let () = let entries = Vcs.read_dir vcs ~dir:(Vcs.Repo_root.to_absolute_path repo_root) in - print_s [%sexp (entries : Fpart.t list)]; + print_s [%sexp (entries : Fsegment.t list)]; [%expect {| (.git) |}]; (match Vcs.Result.read_dir vcs ~dir:(Vcs.Repo_root.to_absolute_path repo_root) with | Error _ -> assert false - | Ok entries -> print_s [%sexp (entries : Fpart.t list)]); + | Ok entries -> print_s [%sexp (entries : Fsegment.t list)]); [%expect {| (.git) |}] in (* Find the root from the root itself. *) @@ -74,11 +74,11 @@ let%expect_test "find_enclosing_repo_root" = Vcs.find_enclosing_repo_root vcs ~from:subdir - ~store:[ Fpart.dot_git; Fpart.dot_hg ] + ~store:[ Fsegment.dot_git; Fsegment.dot_hg ] with | None -> assert false | Some (`Store store, repo_root2) -> - require_equal [%here] (module Fpart) store Fpart.dot_git; + require_equal [%here] (module Fsegment) store Fsegment.dot_git; require_equal [%here] (module Vcs.Repo_root) repo_root repo_root2; [%expect {||}]); (* 2. Non-raising [find_enclosing_repo_root]. *) @@ -86,11 +86,11 @@ let%expect_test "find_enclosing_repo_root" = Vcs.Result.find_enclosing_repo_root vcs ~from:subdir - ~store:[ Fpart.dot_git; Fpart.dot_hg ] + ~store:[ Fsegment.dot_git; Fsegment.dot_hg ] with | Error _ | Ok None -> assert false | Ok (Some (`Store store, repo_root2)) -> - require_equal [%here] (module Fpart) store Fpart.dot_git; + require_equal [%here] (module Fsegment) store Fsegment.dot_git; require_equal [%here] (module Vcs.Repo_root) repo_root repo_root2; [%expect {||}]); (* 3. Raising [find_enclosing_git_repo_root]. *) @@ -109,10 +109,10 @@ let%expect_test "find_enclosing_repo_root" = ~create:(`Or_truncate 0o666) Eio.Path.(Eio.Stdenv.fs env / Absolute_path.to_string stop_at / ".hg") ""; - match Vcs.find_enclosing_repo_root vcs ~from:subdir ~store:[ Fpart.dot_hg ] with + match Vcs.find_enclosing_repo_root vcs ~from:subdir ~store:[ Fsegment.dot_hg ] with | None -> assert false | Some (`Store store, repo_root2) -> - require_equal [%here] (module Fpart) store Fpart.dot_hg; + require_equal [%here] (module Fsegment) store Fsegment.dot_hg; require_equal [%here] (module Vcs.Repo_root) diff --git a/vcs-command.opam b/vcs-command.opam index e3efb96..b2cf9dd 100644 --- a/vcs-command.opam +++ b/vcs-command.opam @@ -18,7 +18,7 @@ depends: [ "eio_main" {>= "1.0"} "err" {>= "0.0.5"} "fpath" {>= "0.7.3"} - "fpath-sexp0" {>= "0.2.0"} + "fpath-sexp0" {>= "0.2.2"} "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 d167f0e..b019672 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-sexp0" {>= "0.2.0"} + "fpath-sexp0" {>= "0.2.2"} "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 11c14b4..cb88b03 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-sexp0" {>= "0.2.0"} + "fpath-sexp0" {>= "0.2.2"} "ppx_compare" {>= "v0.17" & < "v0.18"} "ppx_enumerate" {>= "v0.17" & < "v0.18"} "ppx_hash" {>= "v0.17" & < "v0.18"} diff --git a/vcs-git-provider.opam b/vcs-git-provider.opam index 1248ed2..e21fb45 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-sexp0" {>= "0.2.0"} + "fpath-sexp0" {>= "0.2.2"} "ppx_compare" {>= "v0.17" & < "v0.18"} "ppx_enumerate" {>= "v0.17" & < "v0.18"} "ppx_hash" {>= "v0.17" & < "v0.18"} diff --git a/vcs-test-helpers.opam b/vcs-test-helpers.opam index 086ff2d..ae86e60 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-sexp0" {>= "0.2.0"} + "fpath-sexp0" {>= "0.2.2"} "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 f064f3d..ed70baf 100644 --- a/vcs-tests.opam +++ b/vcs-tests.opam @@ -24,8 +24,8 @@ depends: [ "err" {>= "0.0.5"} "expect_test_helpers_core" {>= "v0.17" & < "v0.18"} "fpath" {>= "0.7.3"} - "fpath-base" {>= "0.2.0"} - "fpath-sexp0" {>= "0.2.0"} + "fpath-base" {>= "0.2.2"} + "fpath-sexp0" {>= "0.2.2"} "mdx" {with-doc & >= "2.4"} "ppx_compare" {>= "v0.17" & < "v0.18"} "ppx_enumerate" {>= "v0.17" & < "v0.18"} diff --git a/vcs.opam b/vcs.opam index 7cea265..064e790 100644 --- a/vcs.opam +++ b/vcs.opam @@ -12,7 +12,7 @@ depends: [ "ocaml" {>= "5.2"} "base" {>= "v0.17" & < "v0.18"} "fpath" {>= "0.7.3"} - "fpath-base" {>= "0.2.0"} + "fpath-base" {>= "0.2.2"} "ppx_compare" {>= "v0.17" & < "v0.18"} "ppx_enumerate" {>= "v0.17" & < "v0.18"} "ppx_hash" {>= "v0.17" & < "v0.18"}