Skip to content

Commit

Permalink
feat(model): Match the type case insensitively in package configurations
Browse files Browse the repository at this point in the history
Make the matching of the identifier type in package configurations case
insensitive to align with package curations.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Feb 13, 2025
1 parent cd855be commit 5956a45
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
9 changes: 8 additions & 1 deletion model/src/main/kotlin/config/PackageConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,14 @@ data class PackageConfiguration(
}

fun matches(otherId: Identifier, provenance: Provenance): Boolean {
if (id != otherId) return false
@Suppress("ComplexCondition")
if (!id.type.equals(otherId.type, ignoreCase = true) ||
id.namespace != otherId.namespace ||
id.name != otherId.name ||
id.version != otherId.version
) {
return false
}

return when (provenance) {
is UnknownProvenance -> false
Expand Down
19 changes: 19 additions & 0 deletions model/src/test/kotlin/config/PackageConfigurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,24 @@ class PackageConfigurationTest : WordSpec({
)
) shouldBe false
}

"return true if the identifier type is equal ignoring case" {
val config =
vcsPackageConfig(name = "some-name", revision = "12345678", url = "ssh://git@host/repo.git").let {
it.copy(id = it.id.copy(type = "Gradle"))
}

config.matches(
config.id.copy(type = "gradle"),
RepositoryProvenance(
vcsInfo = VcsInfo(
type = VcsType.GIT,
url = "ssh://git@host/repo.git",
revision = ""
),
resolvedRevision = "12345678"
)
) shouldBe true
}
}
})

0 comments on commit 5956a45

Please sign in to comment.