@@ -49,6 +49,7 @@ import org.ossreviewtoolkit.model.config.CopyrightGarbage
4949import org.ossreviewtoolkit.model.config.Curations
5050import org.ossreviewtoolkit.model.config.DownloaderConfiguration
5151import org.ossreviewtoolkit.model.config.Excludes
52+ import org.ossreviewtoolkit.model.config.Includes
5253import org.ossreviewtoolkit.model.config.IssueResolution
5354import org.ossreviewtoolkit.model.config.LicenseFindingCuration
5455import org.ossreviewtoolkit.model.config.PackageConfiguration
@@ -58,6 +59,7 @@ import org.ossreviewtoolkit.model.config.Resolutions
5859import org.ossreviewtoolkit.model.config.RuleViolationResolution
5960import org.ossreviewtoolkit.model.config.ScopeExclude
6061import org.ossreviewtoolkit.model.config.VulnerabilityResolution
62+ import org.ossreviewtoolkit.model.config.config.PathInclude
6163import org.ossreviewtoolkit.model.readValue
6264import org.ossreviewtoolkit.model.utils.FindingCurationMatcher
6365import org.ossreviewtoolkit.model.utils.createLicenseInfoResolver
@@ -571,6 +573,25 @@ internal fun Collection<PathExclude>.mergePathExcludes(
571573 return result.values.toList()
572574}
573575
576+ /* *
577+ * Merge the given [PathInclude]s replacing entries with equal [PathInclude.pattern].
578+ * If the given [updateOnlyExisting] is true then only entries with matching [PathInclude.pattern] are merged.
579+ */
580+ internal fun Collection<PathInclude>.mergePathIncludes (
581+ other : Collection <PathInclude >,
582+ updateOnlyExisting : Boolean = false
583+ ): List <PathInclude > {
584+ val result = mutableMapOf<String , PathInclude >()
585+
586+ associateByTo(result) { it.pattern }
587+
588+ other.forEach {
589+ if (! updateOnlyExisting || it.pattern in result) result[it.pattern] = it
590+ }
591+
592+ return result.values.toList()
593+ }
594+
574595/* *
575596 * Return a copy with the [PathExclude]s sorted.
576597 */
@@ -622,6 +643,9 @@ internal fun Collection<VulnerabilityResolution>.mergeVulnerabilityResolutions(
622643 */
623644internal fun RepositoryConfiguration.merge (other : RepositoryConfiguration ): RepositoryConfiguration =
624645 RepositoryConfiguration (
646+ includes = Includes (
647+ paths = includes.paths.mergePathIncludes(other.includes.paths)
648+ ),
625649 excludes = Excludes (
626650 paths = excludes.paths.mergePathExcludes(other.excludes.paths),
627651 scopes = excludes.scopes.mergeScopeExcludes(other.excludes.scopes)
0 commit comments