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
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user