License text curations PoC#12084
Closed
fviernau wants to merge 8 commits into
Closed
Conversation
Allow to configure multiple instances of the same provider type. This flexibility can be used to organize the upcoming identifier-specific license text in a directory separate from the identifier-agnostic custom license texts. Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
For the upcoming license text curations feature it makes more sense to match the curations against `SpdxSingleLicenseExpression`s, compared to matching the IDs of license and expression separately, to not limit the flexibility of the curations without need. Use more speaking parameter names in the `LicenseFactProvider` interface to further clarify the meaning of `licenseId`. Furthermore, re-write the `getLicenseText(String, Identifier)` to interpret the first parameter as `SpdxSingleLicenseExpression`, to prepare for using it from the FTL template. Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
Allow multiple license text variants to be provided for a single
`licenseId` instead of a single concatenated string.
Rationale: Some packages include more than one distinct text for the
same licenseId; forcing a single text required curators to concatenate
variants, which is inflexible. Returning a set enables additive
curation semantics (append/merge) rather than overwrite semantics,
which is more powerful for future tooling. Each text entry can carr
its own metadata (e.g., comment or source), improving traceability.
The signature now returns a set of license text entries for a given
`licenseId` and the helper getLicenseText(licenseId, id) is removed,
since integrations (for example NOTICE template generation) need to
distinguish between single and multiple texts and will need to call
both functions anyway.
Note: The `JvmName` has to be changed to avoid a clash due to the now
equal return type of `Set`.
Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
Prepare for an upcoming change. Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
Prepare for re-use in an upcoming change. Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
Enhance `licensesNotInLicenseFiles()` to optionally keep licenses with text curations. This allows for ensuring, to always include curated texts in the NOTICE files. Signed-off-by: Frank Viernau <frank.viernau@gmail.com>
| appendLine() | ||
| append(exceptionText.text) | ||
| } | ||
|
|
|
|
||
| override fun getLicenseTextsForId(singleLicenseExpression: String, id: Identifier): Set<LicenseText> = | ||
| getCurationsForId(id).mapNotNullTo(mutableSetOf()) { curation -> | ||
| curation.licenseText.takeIf { curation.licenseId.toString() == singleLicenseExpression }?.let { LicenseText(it) } |
|
|
||
| override fun getLicenseTextsForId(singleLicenseExpression: String, id: Identifier): Set<LicenseText> = | ||
| getCurationsForId(id).mapNotNullTo(mutableSetOf()) { curation -> | ||
| curation.licenseText.takeIf { curation.licenseId.toString() == singleLicenseExpression }?.let { LicenseText(it) } |
|
|
||
| override fun getLicenseTextsForId(singleLicenseExpression: String, id: Identifier): Set<LicenseText> = | ||
| getCurationsForId(id).mapNotNullTo(mutableSetOf()) { curation -> | ||
| curation.licenseText.takeIf { curation.licenseId.toString() == singleLicenseExpression }?.let { LicenseText(it) } |
|
|
||
| override fun getLicenseTextsForId(singleLicenseExpression: String, id: Identifier): Set<LicenseText> = | ||
| getCurationsForId(id).mapNotNullTo(mutableSetOf()) { curation -> | ||
| curation.licenseText.takeIf { curation.licenseId.toString() == singleLicenseExpression }?.let { LicenseText(it) } |
|
|
||
| override fun getLicenseTextsForId(singleLicenseExpression: String, id: Identifier): Set<LicenseText> = | ||
| getCurationsForId(id).mapNotNullTo(mutableSetOf()) { curation -> | ||
| curation.licenseText.takeIf { curation.licenseId.toString() == singleLicenseExpression }?.let { LicenseText(it) } |
| val outputFileLicenses = licenseFiles.files.flatMap { it.licenses } | ||
| return resolvedLicenses.filter { it !in outputFileLicenses } | ||
| return resolvedLicenses.filter { resolvedLicense -> | ||
| val hasCurations = input.licenseFactProvider.hasLicenseTextsForId(resolvedLicense.license.toString(), id) |
| */ | ||
| fun hasLicenseText(licenseId: String, id: Identifier): Boolean = | ||
| hasLicenseText(licenseId, id) || hasLicenseText(licenseId) | ||
| fun hasLicenseTexts(singleLicenseExpression: String, id: Identifier): Boolean { |
| fun getNonBlankLicenseText(licenseOrExceptionId: String): String? = getLicenseText(licenseOrExceptionId)?.text | ||
|
|
||
| @JvmName("getLicenseTextsStringForId") | ||
| fun getNonBlankLicenseTextsForId(singleLicenseExpression: String, id: Identifier): Set<String> = |
| @JvmName("getLicenseText") | ||
| fun getNonBlankLicenseText(licenseId: String, id: Identifier): String? = getLicenseText(licenseId, id)?.text | ||
| @JvmName("getLicenseTextsString") | ||
| fun getNonBlankLicenseTexts(singleLicenseExpression: String, id: Identifier): Set<String> = |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #12084 +/- ##
=========================================
Coverage 58.62% 58.62%
Complexity 1825 1825
=========================================
Files 361 361
Lines 13572 13572
Branches 1400 1400
=========================================
Hits 7956 7956
Misses 5114 5114
Partials 502 502
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
PoC now more needed, real impl has been done. |
Member
See #12086 for the concluding PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Initial PoC implementation, to be used as a basis for moving to a consensus on how the
final implementation should look like.
It should include all needed functionality wrt the output notice file.
It does not yet cover how the license fact provider is injected / configured.
See also the ort-config part: oss-review-toolkit/ort-config#446