Skip to content

Commit

Permalink
refactor(VcsInfo): Move matches method into class
Browse files Browse the repository at this point in the history
Up until now the method `VcsInfo.matches(VcsInfo)` method was only
defined and used inside the `Repository` class. With shifing from
`VcsInfo` to `RepositoryProvenance`, we require that matcher inside
of `RepositoryProvenance`. In order to have it available, we move
it into the `VcsInfo` class proper, instead of having it available
only to one class (`RepositoryProvenance`) again by moving it there.

Signed-off-by: Jens Keim <[email protected]>
  • Loading branch information
keimje1 committed Jun 20, 2024
1 parent 980f5ea commit dc15a42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 0 additions & 2 deletions model/src/main/kotlin/Repository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ data class Repository(
* in [nestedRepositories].
*/
fun getRelativePath(vcs: VcsInfo): String? {
fun VcsInfo.matches(other: VcsInfo) = type == other.type && url == other.url && revision == other.revision

val normalizedVcs = vcs.normalize()

if (vcsProcessed.matches(normalizedVcs)) return ""
Expand Down
5 changes: 5 additions & 0 deletions model/src/main/kotlin/VcsInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down

0 comments on commit dc15a42

Please sign in to comment.