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

LicenseChoices: Add repository license choices #3801

Conversation

neubs-bsi
Copy link
Contributor

Resolves #3396.

Introduce license choices that span the whole project scope and can be overwritten by package specific license choices.

@neubs-bsi
Copy link
Contributor Author

cc:@MarcelBochtler

@neubs-bsi neubs-bsi force-pushed the license-choice-repo-config-local branch 2 times, most recently from d8ca3af to 8251705 Compare March 23, 2021 16:04
model/src/main/kotlin/config/LicenseChoices.kt Outdated Show resolved Hide resolved

init {
val choicesWithoutGiven = repositoryLicenseChoices.filter { it.given == null }
require(choicesWithoutGiven.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do repositoryLicenseChoices require a given but packageLicenseChoices do not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When using a package license choice we have a specific effective license of the package a choice (or several) can be applied to, which is most likely to be known before applying the choice. When we have a repository license choice, the license choice would be applied to each package that offers this license as a choice. Making sure that there is a given helps only applying the choice to a wanted given as opposed to all licenses with that choice, which could lead to unwanted choices.
For consistency it would be possible to make given mandatory for packageLicenseChoices, but this was previously discussed before and decided otherwise.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the explanation, can you add that to the code docs, e.g. for the LicenseChoices class or the properties? And maybe also to the documentation from the last commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the explanation to the RepositoryLicenseChoices, but am unsure if this is how and where it belongs.
I also added it to the documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I think this is good enough for now. I just wanted to avoid that when you read this code without knowing the context you stumble over the fact that only one of the properties has this requirement.

evaluator/src/main/kotlin/PackageRule.kt Show resolved Hide resolved
@neubs-bsi neubs-bsi force-pushed the license-choice-repo-config-local branch from 8251705 to 5f357fe Compare March 26, 2021 08:28
@neubs-bsi neubs-bsi requested a review from mnonnenmacher March 26, 2021 08:29
@neubs-bsi neubs-bsi force-pushed the license-choice-repo-config-local branch 2 times, most recently from 5388f7f to a8aaf17 Compare March 26, 2021 15:11
model/src/main/kotlin/config/LicenseChoices.kt Outdated Show resolved Hide resolved

init {
val choicesWithoutGiven = repositoryLicenseChoices.filter { it.given == null }
require(choicesWithoutGiven.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, I think this is good enough for now. I just wanted to avoid that when you read this code without knowing the context you stumble over the fact that only one of the properties has this requirement.

These are meant for license choices that apply to all packages
in the repository.

Signed-off-by: Stephanie Neubauer <Stephanie.Neubauer@bosch.io>
@neubs-bsi neubs-bsi force-pushed the license-choice-repo-config-local branch from a8aaf17 to b604557 Compare March 29, 2021 06:25
@neubs-bsi neubs-bsi requested a review from mnonnenmacher March 29, 2021 06:26
mnonnenmacher
mnonnenmacher previously approved these changes Mar 29, 2021
evaluator/src/test/kotlin/RuleSetTest.kt Outdated Show resolved Hide resolved
}
}
}

private fun PackageRule.LicenseRule.containsLicense(expression: SpdxExpression) =
Copy link
Member

Choose a reason for hiding this comment

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

Nit: The extraction of this function could have happened in a preparing commit, as it's unrelated to the actual change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to leave these changes together. As with the extraction came a fix for the actual test we weren't aware of before.

model/src/main/kotlin/licenses/ResolvedLicenseInfo.kt Outdated Show resolved Hide resolved
Since for a license choice only the concluded is relevant, the license view is
changed to use `ONLY_CONCLUDED`.

Signed-off-by: Stephanie Neubauer <Stephanie.Neubauer@bosch.io>
The order of applying the license choices from the different sources
ensures that the more precise scope is applied first (=prioritized).

Signed-off-by: Stephanie Neubauer <Stephanie.Neubauer@bosch.io>
Enable to use license choices from different sources (e.g. global and
package specific) in a chosen order.

Signed-off-by: Stephanie Neubauer <Stephanie.Neubauer@bosch.io>
Signed-off-by: Stephanie Neubauer <Stephanie.Neubauer@bosch.io>
Resolves oss-review-toolkit#3396.

Signed-off-by: Stephanie Neubauer <Stephanie.Neubauer@bosch.io>
@sschuberth sschuberth merged commit de3668b into oss-review-toolkit:master Mar 29, 2021
@sschuberth sschuberth deleted the license-choice-repo-config-local branch March 29, 2021 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add functionality to handle license choices
3 participants