Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 54aeadd

Browse files
committedNov 7, 2024·
fix(analyzer): Suffix project types with "Project"
To avoid one root cause of duplicate project vs package IDs, add a "Project" suffix to the `type` of project IDs. This change does not affect IDs used in package curation or package configurations as these really only apply to packages, not projects. Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent ac5aded commit 54aeadd

File tree

138 files changed

+305
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+305
-295
lines changed
 

‎analyzer/src/main/kotlin/AnalyzerResultBuilder.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,15 @@ class AnalyzerResultBuilder {
9090
* Add the given [project] to this builder. This function can be used for projects that have been obtained
9191
* independently of a [ProjectAnalyzerResult].
9292
*/
93-
fun addProject(project: Project) = apply { projects += project }
93+
fun addProject(project: Project) =
94+
apply {
95+
if (project.id.type.endsWith("Project")) {
96+
projects += project
97+
} else {
98+
val projectId = project.id.copy(type = "${project.id.type}Project")
99+
projects += project.copy(id = projectId)
100+
}
101+
}
94102

95103
/**
96104
* Add the given [packageSet] to this builder. This function can be used for packages that have been obtained

‎analyzer/src/test/kotlin/AnalyzerResultBuilderTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ class AnalyzerResultBuilderTest : WordSpec() {
7373
private val scope2 = Scope("scope-2", setOf(pkgRef2))
7474

7575
private val project1 = Project.EMPTY.copy(
76-
id = Identifier("type-1", "namespace-1", "project-1", "version-1"),
76+
id = Identifier("Type1Project", "namespace-1", "project-1", "version-1"),
7777
scopeDependencies = setOf(scope1),
7878
definitionFilePath = "project1"
7979
)
8080
private val project2 = Project.EMPTY.copy(
81-
id = Identifier("type-2", "namespace-2", "project-2", "version-2"),
81+
id = Identifier("Type2Project", "namespace-2", "project-2", "version-2"),
8282
scopeDependencies = setOf(scope1, scope2)
8383
)
8484
private val project3 = Project.EMPTY.copy(
85-
id = Identifier("type-1", "namespace-3", "project-1.2", "version-1"),
85+
id = Identifier("Type1Project", "namespace-3", "project-1.2", "version-1"),
8686
scopeNames = setOf("scope-2"),
8787
scopeDependencies = null
8888
)
@@ -297,7 +297,7 @@ class AnalyzerResultBuilderTest : WordSpec() {
297297
.addResult(analyzerResult2)
298298
.build()
299299

300-
mergedResults.dependencyGraphs.keys should containExactlyInAnyOrder("type-1", "type-2")
300+
mergedResults.dependencyGraphs.keys should containExactlyInAnyOrder("Type1Project", "Type2Project")
301301
}
302302

303303
"apply scope excludes" {

0 commit comments

Comments
 (0)