@@ -25,10 +25,8 @@ import java.io.File
25
25
26
26
import org.ossreviewtoolkit.downloader.VersionControlSystem
27
27
import org.ossreviewtoolkit.model.Identifier
28
- import org.ossreviewtoolkit.model.KnownProvenance
29
28
import org.ossreviewtoolkit.model.OrtResult
30
29
import org.ossreviewtoolkit.model.PackageCuration
31
- import org.ossreviewtoolkit.model.RepositoryProvenance
32
30
import org.ossreviewtoolkit.model.VcsInfo
33
31
import org.ossreviewtoolkit.model.config.LicenseFindingCuration
34
32
import org.ossreviewtoolkit.model.config.PathExclude
@@ -70,10 +68,8 @@ internal fun findRepositoryPaths(directory: File): Map<String, Set<String>> {
70
68
71
69
val result = mutableMapOf<String , MutableSet <String >>()
72
70
73
- findRepositories(directory).forEach { (path, provenance) ->
74
- if (provenance is RepositoryProvenance ) {
75
- result.getOrPut(provenance.vcsInfo.url.replaceCredentialsInUri()) { mutableSetOf () } + = path
76
- }
71
+ findRepositories(directory).forEach { (path, vcs) ->
72
+ result.getOrPut(vcs.url.replaceCredentialsInUri()) { mutableSetOf () } + = path
77
73
}
78
74
79
75
return result
@@ -83,17 +79,14 @@ internal fun findRepositoryPaths(directory: File): Map<String, Set<String>> {
83
79
* Search the given [directory] for repositories and return a mapping from paths where each respective repository was
84
80
* found to the corresponding [VcsInfo].
85
81
*/
86
- internal fun findRepositories (directory : File ): Map <String , KnownProvenance > {
82
+ internal fun findRepositories (directory : File ): Map <String , VcsInfo > {
87
83
require(directory.isDirectory)
88
84
89
85
val workingTree = VersionControlSystem .forDirectory(directory)
90
- val nestedVcs = workingTree?.getNested()?.filter { (path, _) ->
86
+ return workingTree?.getNested()?.filter { (path, _) ->
91
87
// Only include nested VCS if they are part of the analyzed directory.
92
88
workingTree.getRootPath().resolve(path).startsWith(directory)
93
89
}.orEmpty()
94
- return nestedVcs.map {
95
- it.key to RepositoryProvenance (it.value, it.value.revision)
96
- }.toMap()
97
90
}
98
91
99
92
/* *
@@ -173,17 +166,15 @@ internal data class ProcessedCopyrightStatement(
173
166
*/
174
167
internal fun getLicenseFindingCurationsByRepository (
175
168
curations : Collection <LicenseFindingCuration >,
176
- nestedRepositories : Map <String , KnownProvenance >
169
+ nestedRepositories : Map <String , VcsInfo >
177
170
): RepositoryLicenseFindingCurations {
178
171
val result = mutableMapOf<String , MutableList <LicenseFindingCuration >>()
179
172
180
- nestedRepositories.forEach { (path, provenance) ->
181
- if (provenance is RepositoryProvenance ) {
182
- val pathExcludesForRepository = result.getOrPut(provenance.vcsInfo.url) { mutableListOf () }
183
- curations.forEach { curation ->
184
- curation.path.withoutPrefix(" $path /" )?.let {
185
- pathExcludesForRepository + = curation.copy(path = it)
186
- }
173
+ nestedRepositories.forEach { (path, vcs) ->
174
+ val pathExcludesForRepository = result.getOrPut(vcs.url) { mutableListOf () }
175
+ curations.forEach { curation ->
176
+ curation.path.withoutPrefix(" $path /" )?.let {
177
+ pathExcludesForRepository + = curation.copy(path = it)
187
178
}
188
179
}
189
180
}
@@ -196,17 +187,15 @@ internal fun getLicenseFindingCurationsByRepository(
196
187
*/
197
188
internal fun getPathExcludesByRepository (
198
189
pathExcludes : Collection <PathExclude >,
199
- nestedRepositories : Map <String , KnownProvenance >
190
+ nestedRepositories : Map <String , VcsInfo >
200
191
): RepositoryPathExcludes {
201
192
val result = mutableMapOf<String , MutableList <PathExclude >>()
202
193
203
- nestedRepositories.forEach { (path, provenance) ->
204
- if (provenance is RepositoryProvenance ) {
205
- val pathExcludesForRepository = result.getOrPut(provenance.vcsInfo.url) { mutableListOf () }
206
- pathExcludes.forEach { pathExclude ->
207
- pathExclude.pattern.withoutPrefix(" $path /" )?.let {
208
- pathExcludesForRepository + = pathExclude.copy(pattern = it)
209
- }
194
+ nestedRepositories.forEach { (path, vcs) ->
195
+ val pathExcludesForRepository = result.getOrPut(vcs.url) { mutableListOf () }
196
+ pathExcludes.forEach { pathExclude ->
197
+ pathExclude.pattern.withoutPrefix(" $path /" )?.let {
198
+ pathExcludesForRepository + = pathExclude.copy(pattern = it)
210
199
}
211
200
}
212
201
}
0 commit comments