Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providers use Result (Vcs_base refactor) #34

Merged
merged 11 commits into from
Oct 22, 2024
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
"cSpell.words": [
"chdir",
"ENOENT",
"fpath",
"janestreet",
"lsplit",
"mkdirs",
"odoc",
"opam",
"pathspec",
"raise_notrace",
"rmtree",
"rresult",
"Stdenv",
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@

### Changed

- Provider interfaces now uses `Vcs.Result` type instead of `Or_error` (#34, @mbarbin).
- Rename what was `Vcs.Result` to `Vcs.Rresult` and introduce `Vcs.Result` whose type is simpler (#33, @mbarbin).
- Moved `ocaml-vcs more-tests` commands at top-level (#28, @mbarbin).

### Deprecated

### Fixed

- Changed some exceptions raised by the `vcs` related libraries to the `Vcs.E` exception (#34, @mbarbin).

### Removed

- Removed `Vcs.Exn.raise_s` since it is causing `bisect_ppx` unvisitable points (#34, @mbarbin).
- Removed package `vcs-arg` and inline what's needed directly in `vcs-command` (#28, @mbarbin).

## 0.0.8 (2024-09-30)
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Only keep sexp related ppx that have no runtime dependency on `base`, such as `s

### Stage 4 - Trait implementation use `Result`

- [ ] Pending
- [x] Completed: Oct. 2024

### Stage 5 - Move `Or_error` module into `Vcs_base`.

Expand Down
36 changes: 18 additions & 18 deletions example/hello_blocking.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ let%expect_test "hello commit" =
in
[%expect
{|
((steps ((Vcs.git ((repo_root /invalid/path) (args ())))))
(error (
(prog git)
(args ())
(exit_status Unknown)
(cwd /invalid/path/)
(stdout "")
(stderr "")
(error ("Unix.Unix_error(Unix.ENOENT, \"chdir\", \"/invalid/path/\")")))))
((steps (
(Vcs.git ((repo_root /invalid/path) (args ())))
((prog git)
(args ())
(exit_status Unknown)
(cwd /invalid/path/)
(stdout "")
(stderr ""))))
(error ("Unix.Unix_error(Unix.ENOENT, \"chdir\", \"/invalid/path/\")")))
|}];
(* Let's also show a case where the command fails due to a user error. *)
let () =
Expand All @@ -99,15 +99,15 @@ let%expect_test "hello commit" =
in
[%expect
{|
((steps ((Vcs.git ((repo_root <REDACTED>) (args (rev-parse INVALID-REF))))))
(error (
(prog git)
(args (rev-parse INVALID-REF))
(exit_status (Exited 128))
(cwd <REDACTED>)
(stdout (INVALID-REF))
(stderr <REDACTED>)
(error "Hello invalid exit code"))))
((steps (
(Vcs.git ((repo_root <REDACTED>) (args (rev-parse INVALID-REF))))
((prog git)
(args (rev-parse INVALID-REF))
(exit_status (Exited 128))
(cwd <REDACTED>)
(stdout INVALID-REF)
(stderr <REDACTED>))))
(error "Hello invalid exit code"))
|}];
(* Here we only use [Eio] to clean up the temporary repo, because [rmtree] is
a convenient function to use in this test. But the point is that the rest
Expand Down
74 changes: 37 additions & 37 deletions example/hello_error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let%expect_test "hello error" =
let redact_sexp sexp =
(* Because the actual error may become too brittle overtime, we actually
redact it. *)
Vcs_test_helpers.redact_sexp sexp ~fields:[ "error/error" ]
Vcs_test_helpers.redact_sexp sexp ~fields:[ "error" ]
in
let () =
match Vcs.init vcs ~path:invalid_path with
Expand All @@ -40,15 +40,15 @@ let%expect_test "hello error" =
in
[%expect
{|
((steps ((Vcs.init ((path /invalid/path)))))
(error (
(prog git)
(args (init .))
(exit_status Unknown)
(cwd /invalid/path)
(stdout "")
(stderr "")
(error <REDACTED>))))
((steps (
(Vcs.init ((path /invalid/path)))
((prog git)
(args (init .))
(exit_status Unknown)
(cwd /invalid/path)
(stdout "")
(stderr ""))))
(error <REDACTED>))
|}];
(* Let's do the same with the non-raising interfaces. *)
let () =
Expand All @@ -58,15 +58,15 @@ let%expect_test "hello error" =
in
[%expect
{|
((steps ((Vcs.init ((path /invalid/path)))))
(error (
(prog git)
(args (init .))
(exit_status Unknown)
(cwd /invalid/path)
(stdout "")
(stderr "")
(error <REDACTED>))))
((steps (
(Vcs.init ((path /invalid/path)))
((prog git)
(args (init .))
(exit_status Unknown)
(cwd /invalid/path)
(stdout "")
(stderr ""))))
(error <REDACTED>))
|}];
let () =
match Vcs.Result.init vcs ~path:invalid_path with
Expand All @@ -75,15 +75,15 @@ let%expect_test "hello error" =
in
[%expect
{|
((steps ((Vcs.init ((path /invalid/path)))))
(error (
(prog git)
(args (init .))
(exit_status Unknown)
(cwd /invalid/path)
(stdout "")
(stderr "")
(error <REDACTED>))))
((steps (
(Vcs.init ((path /invalid/path)))
((prog git)
(args (init .))
(exit_status Unknown)
(cwd /invalid/path)
(stdout "")
(stderr ""))))
(error <REDACTED>))
|}];
let () =
match Vcs.Rresult.init vcs ~path:invalid_path with
Expand All @@ -93,15 +93,15 @@ let%expect_test "hello error" =
[%expect
{|
(Vcs (
(steps ((Vcs.init ((path /invalid/path)))))
(error (
(prog git)
(args (init .))
(exit_status Unknown)
(cwd /invalid/path)
(stdout "")
(stderr "")
(error <REDACTED>)))))
(steps (
(Vcs.init ((path /invalid/path)))
((prog git)
(args (init .))
(exit_status Unknown)
(cwd /invalid/path)
(stdout "")
(stderr ""))))
(error <REDACTED>)))
|}];
()
;;
Loading