Skip to content

Commit 9ac6ba5

Browse files
committed
refactoring(Repository): Remove vcs attributes
Remove `vcs` and `vcsProcessed` attributes from `Repository`, since `RepositoryProvenance` is now the main attribute. Signed-off-by: Jens Keim <[email protected]>
1 parent f847423 commit 9ac6ba5

File tree

10 files changed

+18
-27
lines changed

10 files changed

+18
-27
lines changed

cli-helper/src/main/kotlin/utils/Extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ internal fun OrtResult.getScanResultFor(packageConfiguration: PackageConfigurati
716716
* tree.
717717
*/
718718
internal fun OrtResult.getRepositoryPaths(): Map<String, Set<String>> {
719-
val result = mutableMapOf(repository.vcsProcessed.url to mutableSetOf(""))
719+
val result = mutableMapOf(repository.provenance.vcsInfo.normalize().url to mutableSetOf(""))
720720

721721
repository.nestedRepositories.mapValues { (path, vcsInfo) ->
722722
result.getOrPut(vcsInfo.url) { mutableSetOf() } += path

evaluator/src/main/kotlin/ProjectSourceRule.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ open class ProjectSourceRule(
9393
/**
9494
* Return the [VcsType] of the project's code repository.
9595
*/
96-
fun projectSourceGetVcsType(): VcsType = ortResult.repository.vcsProcessed.type
96+
fun projectSourceGetVcsType(): VcsType = ortResult.repository.provenance.vcsInfo.normalize().type
9797

9898
/**
9999
* Return the file paths matching any of the given [glob expressions][patterns] with its file content matching

evaluator/src/main/kotlin/RuleSet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ fun ruleSet(
159159
licenseInfoResolver: LicenseInfoResolver = ortResult.createLicenseInfoResolver(),
160160
resolutionProvider: ResolutionProvider = DefaultResolutionProvider.create(),
161161
projectSourceResolver: SourceTreeResolver = SourceTreeResolver.forRemoteRepository(
162-
ortResult.repository.vcsProcessed
162+
ortResult.repository.provenance.vcsInfo.normalize()
163163
),
164164
configure: RuleSet.() -> Unit = {}
165165
) = RuleSet(ortResult, licenseInfoResolver, resolutionProvider, projectSourceResolver).apply(configure)

model/src/main/kotlin/Repository.kt

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@ data class Repository(
3333
*/
3434
val provenance: RepositoryProvenance,
3535

36-
/**
37-
* Original VCS-related information from the working tree containing the analyzer root.
38-
*/
39-
val vcs: VcsInfo = provenance.vcsInfo,
40-
41-
/**
42-
* Processed VCS-related information from the working tree containing the analyzer root that has e.g. common
43-
* mistakes corrected.
44-
*/
45-
val vcsProcessed: VcsInfo = vcs.normalize(),
46-
4736
/**
4837
* A map of nested repositories, for example Git submodules or Git-Repo modules. The key is the path to the
4938
* nested repository relative to the root of the main repository.
@@ -66,8 +55,6 @@ data class Repository(
6655
vcsInfo = VcsInfo.EMPTY,
6756
resolvedRevision = HashAlgorithm.SHA1.emptyValue
6857
),
69-
vcs = VcsInfo.EMPTY,
70-
vcsProcessed = VcsInfo.EMPTY,
7158
nestedRepositories = emptyMap(),
7259
config = RepositoryConfiguration()
7360
)
@@ -82,7 +69,7 @@ data class Repository(
8269

8370
val normalizedVcs = vcs.normalize()
8471

85-
if (vcsProcessed.matches(normalizedVcs)) return ""
72+
if (provenance.vcsInfo.normalize().matches(normalizedVcs)) return ""
8673

8774
return nestedRepositories.entries.find { (_, nestedVcs) -> nestedVcs.normalize().matches(normalizedVcs) }?.key
8875
}

model/src/test/kotlin/OrtResultTest.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,10 @@ class OrtResultTest : WordSpec({
379379

380380
val ortResult = OrtResult.EMPTY.copy(
381381
repository = Repository.EMPTY.copy(
382-
vcs = vcs,
383-
vcsProcessed = vcs,
382+
provenance = RepositoryProvenance(
383+
vcsInfo = vcs,
384+
resolvedRevision = vcs.revision
385+
),
384386
config = RepositoryConfiguration(
385387
excludes = Excludes(
386388
paths = listOf(

plugins/reporters/cyclonedx/src/main/kotlin/CycloneDxReporter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class CycloneDxReporter(
154154
// There is no component type for repositories.
155155
type = Component.Type.FILE
156156

157-
with(input.ortResult.repository.vcsProcessed) {
157+
with(input.ortResult.repository.provenance.vcsInfo.normalize()) {
158158
bomRef = "$url@$revision"
159159

160160
name = url
@@ -178,7 +178,7 @@ class CycloneDxReporter(
178178
// distributable), just create a single BOM for all projects in that case for now. As there also is no
179179
// single correct project to pick for adding external references in that case, simply only use the global
180180
// repository VCS information here.
181-
val vcs = input.ortResult.repository.vcsProcessed
181+
val vcs = input.ortResult.repository.provenance.vcsInfo.normalize()
182182
bom.addExternalReference(
183183
ExternalReference.Type.VCS,
184184
vcs.url,

plugins/reporters/opossum/src/main/kotlin/OpossumReporter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class OpossumReporter(
127127
private val externalAttributionSources: MutableMap<String, OpossumExternalAttributionSource> = mutableMapOf()
128128

129129
internal fun create(input: ReporterInput, maxDepth: Int = Int.MAX_VALUE): OpossumInput {
130-
addBaseUrl("/", input.ortResult.repository.vcs)
130+
addBaseUrl("/", input.ortResult.repository.provenance.vcsInfo)
131131

132132
SpdxLicense.entries.forEach {
133133
val licenseText = input.licenseTextProvider.getLicenseText(it.id)

plugins/reporters/spdx/src/testFixtures/kotlin/TestData.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ val ORT_RESULT = OrtResult(
7171
)
7272
)
7373
),
74-
provenance = ANALYZED_PROVENANCE,
75-
vcsProcessed = ANALYZED_VCS
74+
provenance = ANALYZED_PROVENANCE
7675
),
7776
analyzer = AnalyzerRun.EMPTY.copy(
7877
result = AnalyzerResult(

plugins/reporters/static-html/src/main/kotlin/TablesReportModelMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ internal object TablesReportModelMapper {
4848
.sortedBy { it.id }
4949

5050
return TablesReport(
51-
input.ortResult.repository.vcsProcessed,
51+
input.ortResult.repository.provenance.vcsInfo.normalize(),
5252
input.ortResult.repository.config,
5353
ruleViolations,
5454
getAnalyzerIssueSummaryTable(input),

scanner/src/funTest/kotlin/scanners/ScannerIntegrationFunTest.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.ossreviewtoolkit.model.PackageReference
3636
import org.ossreviewtoolkit.model.PackageType
3737
import org.ossreviewtoolkit.model.Project
3838
import org.ossreviewtoolkit.model.Repository
39+
import org.ossreviewtoolkit.model.RepositoryProvenance
3940
import org.ossreviewtoolkit.model.ScanSummary
4041
import org.ossreviewtoolkit.model.Scope
4142
import org.ossreviewtoolkit.model.TextLocation
@@ -167,8 +168,10 @@ private fun createAnalyzerResultWithProject(project: Project, vararg packages: P
167168
return OrtResult.EMPTY.copy(
168169
analyzer = analyzerRun,
169170
repository = Repository.EMPTY.copy(
170-
vcsProcessed = projectWithScope.vcsProcessed,
171-
vcs = projectWithScope.vcs
171+
provenance = RepositoryProvenance(
172+
vcsInfo = projectWithScope.vcs,
173+
resolvedRevision = projectWithScope.vcs.revision
174+
)
172175
)
173176
)
174177
}

0 commit comments

Comments
 (0)