-
Notifications
You must be signed in to change notification settings - Fork 77
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
Attempt conversion of SPDX license expressions to Homebrew DSL #1345
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much! This is quite thorough - I appreciate it. Just a couple of comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Just noticed that two conditions here are parsed differently from how Homebrew does it - wanted to check in and see how you're feeling about that at this point.
added `spdx` dependency for parsing license expression. added to_homebrew_license_format utility function with tests. modified add_homebrew_installer to attempt conversion updated snapshots
507f9e7
to
b9ceed3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
These two tests produce different results in Homebrew's SPDX parser, but that appears to be a bug in Homebrew's parser rather than this one. Added notes to both tests so that we expect the results to be different from what Homebrew returns. refs #1345 (comment).
Resolves #820.
Problem
Currently, when publishing to a Homebrew tap, whatever string is in the crate's Cargo.toml license field (usually a SPDX license expression) gets passed into
license
in the Homebrew formula. However, rather than using SPDX syntax, Homebrew has its own ruby syntax for specifying licenses. So, when passed an SPDX expression, Homebrew:brew audit
/brew test-bot
.Solution
spdx
crate to parse the SPDX license expression.license
command, falling back to the original license string if there are issues parsing.Scope
spdx
crate has not yet implemented v3 of the spec. This means that the WITH operator is not yet covered, and neither are lower-case versions of the operators.spdx
issue for implementing spec v3 is here.Testing
I added tests for the conversion utility function, tested the output in a Homebrew formula, and I inspected and updated the test snapshots. This PR could certainly use some additional testing from someone with deeper familiarity with the project.