Skip to content

Commit

Permalink
feat(helper-cli): Re-filter scan summary by VCS path
Browse files Browse the repository at this point in the history
Analog to [1], re-filter all scan results by VCS path, so that the
effect of narrowing down a VCS path via a package curation is reflected
in the output of `ListLicensesCommand`.

[1]: 2ec49c7

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Nov 9, 2023
1 parent f93e651 commit dcd3b19
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion helper-cli/src/main/kotlin/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import org.ossreviewtoolkit.model.readValue
import org.ossreviewtoolkit.model.utils.FindingCurationMatcher
import org.ossreviewtoolkit.model.utils.PackageConfigurationProvider
import org.ossreviewtoolkit.model.utils.createLicenseInfoResolver
import org.ossreviewtoolkit.model.utils.filterByVcsPath
import org.ossreviewtoolkit.model.writeValue
import org.ossreviewtoolkit.model.yamlMapper
import org.ossreviewtoolkit.utils.common.safeMkdirs
Expand Down Expand Up @@ -179,7 +180,13 @@ internal fun OrtResult.getLicenseFindingsById(
packageConfigurationProvider.getPackageConfigurations(id, provenance).flatMap { it.licenseFindingCurations }
}

getScanResultsForId(id).forEach { scanResult ->
getScanResultsForId(id).map {
// If a VCS path curation has been applied after the scanning stage, it is possible to apply that
// curation without re-scanning in case the new VCS path is a subdirectory of the scanned VCS path.
// So, filter by VCS path to enable the user to see the effect on the detected license with a shorter
// turn around time / without re-scanning.
it.filterByVcsPath(getPackage(id)?.metadata?.vcsProcessed?.path.orEmpty())
}.forEach { scanResult ->
val findingsForProvenance = result.getOrPut(scanResult.provenance) { mutableMapOf() }

scanResult.summary.licenseFindings.let { findings ->
Expand Down

0 comments on commit dcd3b19

Please sign in to comment.