Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint W59 with a local path that is not an archive #6219

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rjbou
Copy link
Collaborator

@rjbou rjbou commented Oct 1, 2024

fix #6218

@rjbou rjbou added the KIND: BUG label Oct 1, 2024
@rjbou rjbou added this to the 2.3.0~alpha2 milestone Oct 1, 2024
@rjbou rjbou requested a review from kit-ty-kate October 1, 2024 09:48
@rjbou rjbou changed the title Fiw lint W59 Fix lint W59 with a local path that is not an archive Oct 1, 2024
tests/reftests/lint.test Outdated Show resolved Hide resolved
### <add-url.sh>
basedir=$(echo $BASEDIR | sed "s/\\\\\\\\/\\\\\\\\\\\\\\\\/g")
cat << EOF >> lint.opam
url { src:"file://$basedir/an-archive" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand the issue. The an-archive directory doesn't exists at this point right? Shouldn't we raise a warning here for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, linting should only check the content of the file and what is required in an opam file. If we want to check things on disk, it should be another option, as for --check-upstream

tests/reftests/lint.test Outdated Show resolved Hide resolved
let url_archive =
let open OpamStd.Option.Op in
t.url >>| OpamFile.URL.url >>| (fun u ->
OpamSystem.is_archive u.OpamUrl.path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think that's right. is_archive will look up the file locally. If you have an url like https:///etc/fstab, the path will be looked up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, we should then add a function that checks if a path looks like an archive, like looks_like_ssh_path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure we need a new function. Something like that would work just fine i think:

Suggested change
OpamSystem.is_archive u.OpamUrl.path)
OpamSystem.local_file u <> None)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to check file existence on disk (which does OpamUrl.local_file). We want to know if given string seems like an archive path.

Copy link
Member

@kit-ty-kate kit-ty-kate Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a function similar to OpamUrl.kind from #5979?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lint W59 warn for missing checksum on local directory source url
2 participants