From 7560c1e4937dd73909f786f595e275e7232035cf Mon Sep 17 00:00:00 2001 From: Raja Boujbel Date: Wed, 8 Mar 2023 19:54:24 +0100 Subject: [PATCH] lint: update W59 (no checksum on url) to always display a warning, no more tied to --check-upstream option --- src/state/opamFileTools.ml | 6 +++--- tests/reftests/archive.test | 3 ++- tests/reftests/lint.test | 3 ++- tests/reftests/show.test | 27 +++++++++++++++------------ 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/state/opamFileTools.ml b/src/state/opamFileTools.ml index db92da7d51c..a43f98a3130 100644 --- a/src/state/opamFileTools.ml +++ b/src/state/opamFileTools.ml @@ -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 @@ -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 diff --git a/tests/reftests/archive.test b/tests/reftests/archive.test index 66f8c8eaded..b1b3ded0cf1 100644 --- a/tests/reftests/archive.test +++ b/tests/reftests/archive.test @@ -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 -/no-checksum.1: Passed. +/no-checksum.1: Warnings. + warning 59: url doesn't contain a checksum ### opam lint --package no-checksum --check-upstream /no-checksum.1: Warnings. warning 59: url doesn't contain a checksum diff --git a/tests/reftests/lint.test b/tests/reftests/lint.test index f857230d955..24d2874a321 100644 --- a/tests/reftests/lint.test +++ b/tests/reftests/lint.test @@ -727,7 +727,8 @@ dev-repo: "hg+https://to@li.nt" 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 diff --git a/tests/reftests/show.test b/tests/reftests/show.test index 7662c4741b6..13650c4ad7f 100644 --- a/tests/reftests/show.test +++ b/tests/reftests/show.test @@ -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" ] @@ -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://pkg@op.am" -authors "the testing team" -maintainer "maint@tain.er" -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://pkg@op.am" +authors "the testing team" +maintainer "maint@tain.er" +license "MIT" +synopsis A word +description Two words. ### opam show ./swhid.opam --raw opam-version: "2.0" name: "swhid" @@ -390,6 +392,7 @@ bug-reports: "https://nobug" dev-repo: "hg+https://pkg@op.am" 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"