internal/rosa: overridable version check
All checks were successful
Test / Hakurei (push) Successful in 2m38s
Test / Sandbox (push) Successful in 1m28s
Test / Create distribution (push) Successful in 28s
Test / ShareFS (push) Successful in 2m40s
Test / Sandbox (race detector) (push) Successful in 4m1s
Test / Hakurei (race detector) (push) Successful in 5m45s
Test / Flake checks (push) Successful in 1m35s

For projects with strange version practices.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-03-06 18:57:55 +09:00
parent 16d0cf04c1
commit ecec634423
2 changed files with 20 additions and 1 deletions

View File

@@ -173,7 +173,7 @@ func main() {
if v, err := meta.GetVersions(ctx); err != nil {
return err
} else if current := rosa.Std.Version(p); v.Latest != current {
} else if current := rosa.Std.Version(p); !meta.IsLatest(v, current) {
n++
log.Printf("%s %s < %s", meta.Name, current, v.Latest)
} else {

View File

@@ -166,6 +166,17 @@ type Metadata struct {
//
// [Anitya]: https://release-monitoring.org/
ID int `json:"-"`
// Optional custom version checking behaviour.
latest func(v *Versions, cur string) bool
}
// IsLatest returns whether cur is the latest version described by v.
func (meta *Metadata) IsLatest(v *Versions, cur string) bool {
if meta.latest != nil {
return meta.latest(v, cur)
}
return v.Latest == cur
}
// Unversioned denotes an unversioned [PArtifact].
@@ -188,6 +199,14 @@ type Versions struct {
All []string `json:"versions"`
}
// checkStable returns whether cur is the latest version described by Stable.
func (v *Versions) checkStable(cur string) bool {
if len(v.Stable) == 0 {
return v.Latest == cur
}
return v.Stable[0] == cur
}
// GetVersions returns versions fetched from Anitya.
func (meta *Metadata) GetVersions(ctx context.Context) (*Versions, error) {
if meta.ID == 0 {