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

refactor(pkg): stop validating stuff we don't use #9030

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions src/dune_pkg/opam_repo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ let equal { source; serializable } t =
&& Option.equal Serializable.equal serializable t.serializable
;;

let minimum_opam_version = OpamVersion.of_string "2.0"
let serializable { serializable; _ } = serializable

let repo_id t =
Expand All @@ -73,54 +72,6 @@ let source t =
serializable.source
;;

let validate_repo_file opam_repo_dir_path =
let opam_repo_file_path = opam_repo_dir_path / "repo" in
let repo =
try
OpamFilename.raw (Path.to_string opam_repo_file_path)
|> OpamFile.make
|> OpamFile.Repo.read
with
| OpamSystem.Internal_error message -> User_error.raise [ Pp.text message ]
| OpamPp.(Bad_format _ | Bad_format_list _ | Bad_version _) as bad_format_exn ->
User_error.raise [ Pp.text (OpamPp.string_of_bad_format bad_format_exn) ]
| unexpected_exn ->
Code_error.raise
"Unexpected exception raised while validating opam repo files"
[ "exception", Exn.to_dyn unexpected_exn
; "opam_repo_dir_path", Path.to_dyn opam_repo_file_path
]
in
match OpamFile.Repo.opam_version repo with
| None ->
User_error.raise
[ Pp.textf
"The file %s lacks an \"opam-version\" field."
(Path.to_string_maybe_quoted opam_repo_file_path)
]
~hints:
[ Pp.textf
"Add `opam-version: \"%s\"` to the file."
(OpamVersion.to_string minimum_opam_version)
]
| Some opam_version ->
if OpamVersion.compare opam_version minimum_opam_version < 0
then
User_error.raise
[ Pp.textf
"The file %s specifies an opam-version which is too low (%s). The minimum \
opam-version is %s."
(Path.to_string_maybe_quoted opam_repo_file_path)
(OpamVersion.to_string opam_version)
(OpamVersion.to_string minimum_opam_version)
]
~hints:
[ Pp.textf
"Change the opam-version field to `opam-version: \"%s\"`."
(OpamVersion.to_string minimum_opam_version)
]
;;

let of_opam_repo_dir_path ~source ~repo_id opam_repo_dir_path =
if not (Path.exists opam_repo_dir_path)
then
Expand All @@ -140,7 +91,6 @@ let of_opam_repo_dir_path ~source ~repo_id opam_repo_dir_path =
named \"packages\""
(Path.to_string_maybe_quoted opam_repo_dir_path)
];
validate_repo_file opam_repo_dir_path;
let serializable =
Option.map source ~f:(fun source -> { Serializable.repo_id; source })
in
Expand Down
3 changes: 0 additions & 3 deletions test/blackbox-tests/test-cases/pkg/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ show_pkg_cookie() {

mkrepo() {
mkdir -p mock-opam-repository
cat >mock-opam-repository/repo <<EOF
opam-version: "2.0"
EOF
}

mock_packages="mock-opam-repository/packages"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,3 @@ Test the error cases for invalid opam repositories
doesn't look like a path to an opam repository as it lacks a subdirectory
named "packages"
[1]

$ dune pkg lock --opam-repository-path=no-repo-file
Error: File
$TESTCASE_ROOT/no-repo-file/repo
does not exist or can't be read
[1]

$ dune pkg lock --opam-repository-path=bad-repo-file
Error: At
$TESTCASE_ROOT/bad-repo-file/repo:1:4-1:8::
Parse error
[1]

$ dune pkg lock --opam-repository-path=no-repo-version
Error: The file
$TESTCASE_ROOT/no-repo-version/repo
lacks an "opam-version" field.
Hint: Add `opam-version: "2.0"` to the file.
[1]

$ dune pkg lock --opam-repository-path=bad-repo-version
Error: The file
$TESTCASE_ROOT/bad-repo-version/repo
specifies an opam-version which is too low (1.0). The minimum opam-version is
2.0.
Hint: Change the opam-version field to `opam-version: "2.0"`.
[1]