From d477132c2c378ef29221cb025ca86b94fc6408dc Mon Sep 17 00:00:00 2001 From: Jens Keim Date: Thu, 20 Jun 2024 14:04:38 +0200 Subject: [PATCH] fix(Provenance): Fix `matches` method --- model/src/main/kotlin/Provenance.kt | 7 ++++++- model/src/main/kotlin/VcsInfo.kt | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/model/src/main/kotlin/Provenance.kt b/model/src/main/kotlin/Provenance.kt index 9f200454320d1..f0d2a535e7885 100644 --- a/model/src/main/kotlin/Provenance.kt +++ b/model/src/main/kotlin/Provenance.kt @@ -85,7 +85,12 @@ data class RepositoryProvenance( * Return true if this provenance matches the processed VCS information of the [package][pkg]. */ override fun matches(pkg: Package): Boolean = vcsInfo == pkg.vcsProcessed - override fun matches(other: KnownProvenance): Boolean = other is RepositoryProvenance && vcsInfo == other.vcsInfo + + /** + * Return true if this provenance matches the [knownProvenance][other]. + */ + override fun matches(other: KnownProvenance): Boolean = + other is RepositoryProvenance && other.vcsInfo.normalize().matches(vcsInfo.normalize()) } /** diff --git a/model/src/main/kotlin/VcsInfo.kt b/model/src/main/kotlin/VcsInfo.kt index 62342f06eddcd..43904ecd6f228 100644 --- a/model/src/main/kotlin/VcsInfo.kt +++ b/model/src/main/kotlin/VcsInfo.kt @@ -83,6 +83,11 @@ data class VcsInfo( * Return a [VcsInfoCurationData] with the properties from this [VcsInfo]. */ fun toCuration() = VcsInfoCurationData(type, url, revision, path) + + /** + * Return true if this vcs information matches the other vcs information. + */ + fun matches(other: VcsInfo) = type == other.type && url == other.url && revision == other.revision } /**