Skip to content

Commit

Permalink
refactor(Repository): Allow Provenance.matches(Provenance)
Browse files Browse the repository at this point in the history
Instead of limiting the `Provenance.matches()` method to
`KnownProvenance`, we allow any Provenance. This should
work just as well, since KnownProvenances are required to
compare the type of the given (Known)Provenance anyway.

Signed-off-by: Jens Keim <[email protected]>
  • Loading branch information
pepper-jk committed Jun 26, 2024
1 parent d413bb6 commit ee0c82a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions model/src/main/kotlin/Provenance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ sealed interface Provenance {
* True if this [Provenance] refers to the same source code as [pkg], assuming that it belongs to the package id.
*/
fun matches(pkg: Package): Boolean
fun matches(other: KnownProvenance): Boolean
fun matches(other: Provenance): Boolean
}

data object UnknownProvenance : Provenance {
override fun matches(pkg: Package): Boolean = false
override fun matches(other: KnownProvenance): Boolean = false
override fun matches(other: Provenance): Boolean = false
}

sealed interface KnownProvenance : Provenance
Expand All @@ -55,7 +55,7 @@ data class ArtifactProvenance(
val sourceArtifact: RemoteArtifact
) : KnownProvenance {
override fun matches(pkg: Package): Boolean = sourceArtifact == pkg.sourceArtifact
override fun matches(other: KnownProvenance): Boolean =
override fun matches(other: Provenance): Boolean =
other is ArtifactProvenance && sourceArtifact == other.sourceArtifact
}

Expand Down Expand Up @@ -89,7 +89,7 @@ data class RepositoryProvenance(
/**
* Return true if this provenance matches the [knownProvenance][other].
*/
override fun matches(other: KnownProvenance): Boolean =
override fun matches(other: Provenance): Boolean =
other is RepositoryProvenance && other.vcsInfo.normalize().matches(vcsInfo.normalize())
}

Expand Down

0 comments on commit ee0c82a

Please sign in to comment.