Skip to content

Commit 5956a45

Browse files
committedFeb 13, 2025·
feat(model): Match the type case insensitively in package configurations
Make the matching of the identifier type in package configurations case insensitive to align with package curations. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
1 parent cd855be commit 5956a45

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
 

‎model/src/main/kotlin/config/PackageConfiguration.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,14 @@ data class PackageConfiguration(
7171
}
7272

7373
fun matches(otherId: Identifier, provenance: Provenance): Boolean {
74-
if (id != otherId) return false
74+
@Suppress("ComplexCondition")
75+
if (!id.type.equals(otherId.type, ignoreCase = true) ||
76+
id.namespace != otherId.namespace ||
77+
id.name != otherId.name ||
78+
id.version != otherId.version
79+
) {
80+
return false
81+
}
7582

7683
return when (provenance) {
7784
is UnknownProvenance -> false

‎model/src/test/kotlin/config/PackageConfigurationTest.kt

+19
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,24 @@ class PackageConfigurationTest : WordSpec({
136136
)
137137
) shouldBe false
138138
}
139+
140+
"return true if the identifier type is equal ignoring case" {
141+
val config =
142+
vcsPackageConfig(name = "some-name", revision = "12345678", url = "ssh://git@host/repo.git").let {
143+
it.copy(id = it.id.copy(type = "Gradle"))
144+
}
145+
146+
config.matches(
147+
config.id.copy(type = "gradle"),
148+
RepositoryProvenance(
149+
vcsInfo = VcsInfo(
150+
type = VcsType.GIT,
151+
url = "ssh://git@host/repo.git",
152+
revision = ""
153+
),
154+
resolvedRevision = "12345678"
155+
)
156+
) shouldBe true
157+
}
139158
}
140159
})

0 commit comments

Comments
 (0)
Please sign in to comment.