Skip to content

Commit

Permalink
lint: fix extra-files handling
Browse files Browse the repository at this point in the history
bug introduced in ocaml#5068
  • Loading branch information
rjbou committed Aug 22, 2023
1 parent f60733a commit cedccf7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
16 changes: 7 additions & 9 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand All @@ -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))
Expand All @@ -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,
Expand Down
8 changes: 2 additions & 6 deletions tests/reftests/lint.test
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,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
<default>/lint.2: Errors.
error 53: Mismatching 'extra-files:' field: "more-file-good-md5"
# Return code 1 #
<default>/lint.2: Passed.
### OPAMREPOSITORYTARRING=1
### opam update default

Expand All @@ -570,9 +568,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
<default>/lint.2: Errors.
error 53: Mismatching 'extra-files:' field: "more-file-good-md5"
# Return code 1 #
<default>/lint.2: Passed.
### : W54: External dependencies should not contain spaces nor empty string
### <lint.opam>
opam-version: "2.0"
Expand Down

0 comments on commit cedccf7

Please sign in to comment.