aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-03-06 18:57:55 +0900
committerOphestra <cat@gensokyo.uk>2026-03-06 19:13:55 +0900
commit95ffe0429cbbe839bfc20e04821b23c24f253dfd (patch)
treea1b58ed094996e84c8a74bf0036dafb9ecc9c28f /internal
parent16d0cf04c1b9a5bab1bf872425cf7589e5436dfc (diff)
internal/rosa: overridable version check
For projects with strange versioning practices. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/rosa/all.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/rosa/all.go b/internal/rosa/all.go
index a550b7b9..ddaa1b0d 100644
--- a/internal/rosa/all.go
+++ b/internal/rosa/all.go
@@ -166,6 +166,17 @@ type Metadata struct {
//
// [Anitya]: https://release-monitoring.org/
ID int `json:"-"`
+
+ // Optional custom version checking behaviour.
+ latest func(v *Versions) string
+}
+
+// GetLatest returns the latest version described by v.
+func (meta *Metadata) GetLatest(v *Versions) string {
+ if meta.latest != nil {
+ return meta.latest(v)
+ }
+ return v.Latest
}
// Unversioned denotes an unversioned [PArtifact].
@@ -188,6 +199,14 @@ type Versions struct {
All []string `json:"versions"`
}
+// getStable returns the first Stable version, or Latest if that is unavailable.
+func (v *Versions) getStable() string {
+ if len(v.Stable) == 0 {
+ return v.Latest
+ }
+ return v.Stable[0]
+}
+
// GetVersions returns versions fetched from Anitya.
func (meta *Metadata) GetVersions(ctx context.Context) (*Versions, error) {
if meta.ID == 0 {