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 29, 2023
1 parent 9a8d3bb commit 7560c1e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,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 @@ -700,7 +700,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
3 changes: 2 additions & 1 deletion tests/reftests/lint.test
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,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 7560c1e

Please sign in to comment.