From 1ec12b01cbf1a723f72d3069e66ee4ad1bb0b7a6 Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Mon, 27 Mar 2023 17:14:34 +0200 Subject: [PATCH] lint: fix extra-files handling bug introduced in #5068 --- src/client/opamCommands.ml | 16 +++++++--------- tests/reftests/lint.test | 8 ++------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/client/opamCommands.ml b/src/client/opamCommands.ml index 155ec6fa3b0..89b59c00ec3 100644 --- a/src/client/opamCommands.ml +++ b/src/client/opamCommands.ml @@ -3826,8 +3826,8 @@ let lint cli = let opam = OpamSwitchState.opam st nv in match OpamPinned.orig_opam_file st (OpamPackage.name nv) opam with | None -> raise Not_found - | Some f -> - let filename = + | Some file -> + let label = match OpamFile.OPAM.metadata_dir opam with | None -> None | Some (None, abs) -> @@ -3844,7 +3844,7 @@ let lint cli = (OpamRepositoryName.to_string repo) (OpamPackage.to_string nv)) in - [`pkg (OpamFilename.read (OpamFile.filename f), filename)] + [`pkg (file, label)] with Not_found -> OpamConsole.error_and_exit `Not_found "No opam file found for %s%s" (OpamPackage.Name.to_string (fst pkg)) @@ -3870,12 +3870,10 @@ let lint cli = | `file f -> OpamFileTools.lint_file ~check_upstream ~handle_dirname:true f, Some (OpamFile.to_string f) - | `pkg (content, filename) -> - OpamFileTools.lint_string - ~check_upstream ~handle_dirname:false - OpamStd.Option.(default stdin_f (map to_file filename)) - content, - filename + | `pkg (file, label) -> + OpamFileTools.lint_file ~check_upstream ~handle_dirname:false + file, + label | `stdin -> OpamFileTools.lint_channel ~check_upstream ~handle_dirname:false stdin_f stdin, diff --git a/tests/reftests/lint.test b/tests/reftests/lint.test index 48653495c9e..ffa0c9353cd 100644 --- a/tests/reftests/lint.test +++ b/tests/reftests/lint.test @@ -559,9 +559,7 @@ echo "extra-files: [ \"more-file-good-md5\" \"md5=$hsh\" ]" >> REPO/packages/lin error 53: Mismatching 'extra-files:' field: "more-file-bad-md5" # Return code 1 # ### opam lint --package lint.2 -/lint.2: Errors. - error 53: Mismatching 'extra-files:' field: "more-file-good-md5" -# Return code 1 # +/lint.2: Passed. ### OPAMREPOSITORYTARRING=1 ### opam update default @@ -572,9 +570,7 @@ echo "extra-files: [ \"more-file-good-md5\" \"md5=$hsh\" ]" >> REPO/packages/lin error 53: Mismatching 'extra-files:' field: "more-file-bad-md5" # Return code 1 # ### opam lint --package lint.2 -/lint.2: Errors. - error 53: Mismatching 'extra-files:' field: "more-file-good-md5" -# Return code 1 # +/lint.2: Passed. ### : W54: External dependencies should not contain spaces nor empty string ### opam-version: "2.0"