Skip to content

Commit

Permalink
lint: fix W59 for local url (rsync) that are not archives
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbou committed Oct 14, 2024
1 parent f0301f4 commit 593fb2e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ users)
## Source

## Lint
* [BUG] fix lint W59 with local urls that are not archives [#6219 @rjbou - fix #6218]

## Repository

Expand Down
12 changes: 9 additions & 3 deletions src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,15 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t =
| #OpamUrl.version_control -> true
| _ -> false)
in
let url_archive =
let open OpamStd.Option.Op in
t.url >>| OpamFile.URL.url >>| (fun u ->
OpamSystem.is_archive_from_string u.OpamUrl.path)
in
let is_url_archive =
not (OpamFile.OPAM.has_flag Pkgflag_Conf t) &&
url_vcs = Some false
not (OpamFile.OPAM.has_flag Pkgflag_Conf t)
&& url_vcs = Some false
&& url_archive = Some true
in
let check_upstream = check_upstream && is_url_archive in
let check_double compare to_str lst =
Expand Down Expand Up @@ -1001,7 +1007,7 @@ let t_lint ?check_extra_files ?(check_upstream=false) ?(all=false) t =
|> List.map OpamHash.to_string
|> OpamStd.Format.pretty_list)])
t.url)
(url_vcs = Some true
(url_vcs = Some true && url_archive = Some false
&& OpamStd.Option.Op.(t.url >>| fun u -> OpamFile.URL.checksum u <> [])
= Some true);
cond 68 `Warning
Expand Down
8 changes: 2 additions & 6 deletions tests/reftests/lint.test
Original file line number Diff line number Diff line change
Expand Up @@ -909,13 +909,9 @@ url { src:"file://$basedir/an-archive" }
EOF
### sh add-url.sh
### opam lint ./lint.opam
${BASEDIR}/lint.opam: Warnings.
warning 59: url doesn't contain a checksum
${BASEDIR}/lint.opam: Passed.
### opam lint ./lint.opam --check-upstream
${BASEDIR}/lint.opam: Errors.
warning 59: url doesn't contain a checksum
error 60: Upstream check failed: "Source not found: ${BASEDIR}/an-archive"
# Return code 1 #
${BASEDIR}/lint.opam: Passed.
### # package with local archive url
### <lint.opam>
opam-version: "2.0"
Expand Down
6 changes: 0 additions & 6 deletions tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,6 @@ The following actions will be performed:
-> installed nip-path.ved
Done.
### opam pin edit nip-path
[WARNING] The opam file didn't pass validation:
warning 59: url doesn't contain a checksum
Proceed anyway ('no' will re-edit)? [y/n] y
You can edit this file again with "opam pin edit nip-path", export it with "opam show nip-path --raw"
Save the new opam file back to "${BASEDIR}/nip-path/nip-path.opam"? [y/n] y
The following actions will be performed:
Expand All @@ -523,9 +520,6 @@ The following actions will be performed:
# Return code 31 #
### opam pin add ./nip-path2 --edit
Package nip-path2 does not exist, create as a NEW package? [y/n] y
[WARNING] The opam file didn't pass validation:
warning 59: url doesn't contain a checksum
Proceed anyway ('no' will re-edit)? [y/n] y
You can edit this file again with "opam pin edit nip-path2", export it with "opam show nip-path2 --raw"
nip-path2 is now pinned to file://${BASEDIR}/nip-path2 (version ved)

Expand Down

0 comments on commit 593fb2e

Please sign in to comment.