-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(Repository): Use KnownProvenance instead of VcsInfo #8764
base: main
Are you sure you want to change the base?
Changes from all commits
73f851a
9ffaeb0
7969f0b
ba2a2a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,16 @@ 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 | ||
|
||
/** | ||
|
||
* True if this [Provenance] matches the [Provenance][other] both in type and attributes. | ||
*/ | ||
fun matches(other: Provenance): Boolean | ||
} | ||
|
||
data object UnknownProvenance : Provenance { | ||
override fun matches(pkg: Package): Boolean = false | ||
override fun matches(other: Provenance): Boolean = false | ||
} | ||
|
||
sealed interface KnownProvenance : Provenance | ||
|
@@ -53,6 +59,8 @@ data class ArtifactProvenance( | |
val sourceArtifact: RemoteArtifact | ||
) : KnownProvenance { | ||
override fun matches(pkg: Package): Boolean = sourceArtifact == pkg.sourceArtifact | ||
override fun matches(other: Provenance): Boolean = | ||
other is ArtifactProvenance && sourceArtifact == other.sourceArtifact | ||
} | ||
|
||
/** | ||
|
@@ -72,13 +80,23 @@ data class RepositoryProvenance( | |
val resolvedRevision: String | ||
) : KnownProvenance { | ||
init { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why haven't you decided for keeping the require as-is, and make the tests construct instances with non-empty resolved revision? I'm asking to me it seems that if repository provenance is sued, the VCS info should not be empty, because otherwise it would be an Unkown provenance, wouldn't it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are probably correct. Changing the tests¹ to use However, the Analyzer also allows I have not yet noticed any issues regarding non- Still you are bringing up some good points, maybe the ¹ evaluator/src/test/kotlin/TestData.kt |
||
require(resolvedRevision.isNotBlank()) { "The resolved revision must not be blank." } | ||
require(resolvedRevision.isNotBlank() || vcsInfo == VcsInfo.EMPTY) { | ||
"The resolved revision must not be blank." | ||
} | ||
} | ||
|
||
/** | ||
* Return true if this provenance matches the processed VCS information of the [package][pkg]. | ||
*/ | ||
override fun matches(pkg: Package): Boolean = vcsInfo == pkg.vcsProcessed | ||
|
||
/** | ||
* Return true if the [Provenance][other] is a [RepositoryProvenance] and its normalized vcsInfo matches this | ||
* provenance's normalized [VcsInfo][vcsInfo]. | ||
*/ | ||
override fun matches(other: Provenance): Boolean = | ||
other is RepositoryProvenance && resolvedRevision == other.resolvedRevision && | ||
other.vcsInfo.normalize().equalsDisregardingPath(vcsInfo.normalize()) | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,11 @@ data class VcsInfo( | |
* Return a [VcsInfoCurationData] with the properties from this [VcsInfo]. | ||
*/ | ||
fun toCuration() = VcsInfoCurationData(type, url, revision, path) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commit message nits:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
EDIT: had to force push the old version, in order to see your reviews on the correct commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pushed new commits with code changes only. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just pushed the squashed commits with the overhauled messages. |
||
/** | ||
* Return true if this [VcsInfo] equals the given [VcsInfo][other], disregarding the path. | ||
*/ | ||
fun equalsDisregardingPath(other: VcsInfo) = type == other.type && url == other.url && revision == other.revision | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit message:
Repository
class" (use backticks so it's clear you refer to the class name)