validateNoDuplicateIDs checks that all items have unique IDs extracted by idFunc. The onDuplicate callback creates the error to return when a duplicate is found.
(items []T, idFunc func(T) string, onDuplicate func(string) error)
| 214 | // validateNoDuplicateIDs checks that all items have unique IDs extracted by idFunc. |
| 215 | // The onDuplicate callback creates the error to return when a duplicate is found. |
| 216 | func validateNoDuplicateIDs[T any](items []T, idFunc func(T) string, onDuplicate func(string) error) error { |
| 217 | seen := make(map[string]struct{}) |
| 218 | for _, item := range items { |
| 219 | id := idFunc(item) |
| 220 | if _, ok := seen[id]; ok { |
| 221 | return onDuplicate(id) |
| 222 | } |
| 223 | seen[id] = struct{}{} |
| 224 | } |
| 225 | return nil |
| 226 | } |
| 227 | |
| 228 | // containsTrigger reports whether the given 'on:' section value includes |
| 229 | // the named trigger. It handles the three GitHub Actions forms: |
no outgoing calls
no test coverage detected