Skip to content

Commit

Permalink
lint: update W59 (no checksum on url) to always display a warning, no…
Browse files Browse the repository at this point in the history
… more tied to --check-upstream option
  • Loading branch information
rjbou committed Aug 26, 2024
1 parent 5a92d4e commit e48ae8a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ users)
* Add E71 to check same kind duplicated url checksums in `url` section [#5561 @rjbou]
* Add E72 to check same kind duplicated url checksums in `extra-sources` sections [#5561 @rjbou]
* Add E73 to check that paths in `extra-files:` are not escapable [#5561 @rjbou]
* Update W59 (no checksum in `url`) to always display a warning, untie it from `--check-upstream` option [#5561 @rjbou]

## Repository
* Mitigate curl/curl#13845 by falling back from --write-out to --fail if exit code 43 is returned by curl [#6168 @dra27 - fix #6120]
Expand Down
6 changes: 3 additions & 3 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,11 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t =
| #OpamUrl.version_control -> true
| _ -> false)
in
let check_upstream =
check_upstream &&
let is_url_archive =
not (OpamFile.OPAM.has_flag Pkgflag_Conf t) &&
url_vcs = Some false
in
let check_upstream = check_upstream && is_url_archive in
let check_double compare to_str lst =
let double =
List.sort compare lst
Expand Down Expand Up @@ -811,7 +811,7 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t =
Printf.sprintf "Found %s variable%s, predefined one%s" var s_ nvar)
(rem_test || rem_doc));
cond 59 `Warning "url doesn't contain a checksum"
(check_upstream &&
(is_url_archive &&
OpamStd.Option.map OpamFile.URL.checksum t.url = Some []);
(let upstream_error =
if not check_upstream then None else
Expand Down
3 changes: 2 additions & 1 deletion tests/reftests/archive.test
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ Successfully extracted to ${BASEDIR}/good-sha256-good-md5.1
Clearing cache of downloaded files
### :I:5: no checksum
### opam lint --package no-checksum
<default>/no-checksum.1: Passed.
<default>/no-checksum.1: Warnings.
warning 59: url doesn't contain a checksum
### opam lint --package no-checksum --check-upstream
<default>/no-checksum.1: Warnings.
warning 59: url doesn't contain a checksum
Expand Down
8 changes: 6 additions & 2 deletions tests/reftests/lint.test
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ homepage: "egapemoh"
maintainer: "[email protected]"
license: "ISC"
bug-reports: "https://nobug"
url { src:"https://u.rl" }
url {
src:"an-archive.tgz"
checksum: "md5=00000000000000000000000000000000"
}
### opam lint ./lint.opam
${BASEDIR}/lint.opam: Warnings.
warning 37: Missing field 'dev-repo'
Expand Down Expand Up @@ -852,7 +855,8 @@ dev-repo: "hg+https://[email protected]"
bug-reports: "https://nobug"
url { src:"an-archive.tgz" }
### opam lint ./lint.opam
${BASEDIR}/lint.opam: Passed.
${BASEDIR}/lint.opam: Warnings.
warning 59: url doesn't contain a checksum
### opam lint ./lint.opam --check-upstream
${BASEDIR}/lint.opam: Warnings.
warning 59: url doesn't contain a checksum
Expand Down
27 changes: 15 additions & 12 deletions tests/reftests/show.test
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ depexts devel/llvm10 llvm-10-dev
opam-version: "2.0"
url {
src:"https://an.arch/i/ve.tgz"
checksum: "md5=00000000000000000000000000000000"
mirrors:
[ "https://a.mi/rror"
"http://swhid.opam.ocaml.org/swh:1:dir:309cf2674ee7a0749978cf8265ab91a60aea0f7d" ]
Expand All @@ -364,18 +365,19 @@ name swhid
all-versions dev

<><> Version-specific details <><><><><><><><><><><><><><><><><><><><><><><><><>
version dev
pin https://an.arch/i/ve.tgz
url.src "https://an.arch/i/ve.tgz"
url.swhid "swh:1:dir:309cf2674ee7a0749978cf8265ab91a60aea0f7d"
homepage "egapemoh"
bug-reports "https://nobug"
dev-repo "hg+https://[email protected]"
authors "the testing team"
maintainer "[email protected]"
license "MIT"
synopsis A word
description Two words.
version dev
pin https://an.arch/i/ve.tgz
url.src "https://an.arch/i/ve.tgz"
url.swhid "swh:1:dir:309cf2674ee7a0749978cf8265ab91a60aea0f7d"
url.checksum "md5=00000000000000000000000000000000"
homepage "egapemoh"
bug-reports "https://nobug"
dev-repo "hg+https://[email protected]"
authors "the testing team"
maintainer "[email protected]"
license "MIT"
synopsis A word
description Two words.
### opam show ./swhid.opam --raw
opam-version: "2.0"
name: "swhid"
Expand All @@ -390,6 +392,7 @@ bug-reports: "https://nobug"
dev-repo: "hg+https://[email protected]"
url {
src: "https://an.arch/i/ve.tgz"
checksum: "md5=00000000000000000000000000000000"
mirrors: [
"https://swhid.opam.ocaml.org/swh:1:dir:309cf2674ee7a0749978cf8265ab91a60aea0f7d"
"https://a.mi/rror"
Expand Down

0 comments on commit e48ae8a

Please sign in to comment.