fix(filters): multi-single value dynamic range matching (#2033)

This commit is contained in:
ze0s 2025-05-01 15:08:37 +02:00 committed by GitHub
parent 7c5f5ac9fd
commit a0dfe89032
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 98 additions and 16 deletions

View file

@ -504,11 +504,11 @@ func (f *Filter) CheckFilter(r *Release) (*RejectionReasons, bool) {
}
if len(f.MatchHDR) > 0 && !matchHDR(r.HDR, f.MatchHDR) {
f.RejectReasons.Add("match hdr", r.HDR, f.MatchHDR)
f.RejectReasons.Add("match hdr", strings.Join(r.HDR, " "), f.MatchHDR)
}
if len(f.ExceptHDR) > 0 && matchHDR(r.HDR, f.ExceptHDR) {
f.RejectReasons.Add("except hdr", r.HDR, f.ExceptHDR)
f.RejectReasons.Add("except hdr", strings.Join(r.HDR, " "), f.ExceptHDR)
}
// Other is parsed into the Other slice from rls
@ -1168,6 +1168,7 @@ func matchHDR(releaseValues []string, filterValues []string) bool {
filter = strings.TrimSpace(filter)
filter = strings.ToLower(filter)
// for filter with dual tag like "DV HDR"
parts := strings.Split(filter, " ")
if len(parts) == 2 {
partsMatched := 0
@ -1186,14 +1187,31 @@ func matchHDR(releaseValues []string, filterValues []string) bool {
}
}
} else {
for _, tag := range releaseValues {
if tag == "" {
continue
matches := 0
if len(releaseValues) == 2 {
for _, tag := range releaseValues {
if tag == "" {
continue
}
tag = strings.ToLower(tag)
if tag == filter {
matches++
}
}
tag = strings.ToLower(tag)
if tag == filter {
if matches == len(releaseValues) {
return true
}
} else {
for _, tag := range releaseValues {
if tag == "" {
continue
}
tag = strings.ToLower(tag)
if tag == filter {
return true
}
}
}
}
}