improve constraint matching, migration structure
This commit is contained in:
@@ -4,11 +4,19 @@ package version
|
||||
type List []*Version
|
||||
|
||||
// Match tests versions against a constraint and returns a new List of matching versions only.
|
||||
func (list List) Match(c *Constraint) List {
|
||||
func (list List) Match(constraints ...*Constraint) List {
|
||||
filtered := List{}
|
||||
|
||||
for _, v := range list {
|
||||
if v.Match(c) {
|
||||
ok := true
|
||||
for _, c := range constraints {
|
||||
if !v.Match(c) {
|
||||
ok = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if ok {
|
||||
filtered = append(filtered, v)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user