MCPcopy Create free account
hub / github.com/github/gh-aw / validateNoDuplicateIDs

Function validateNoDuplicateIDs

pkg/workflow/validation_helpers.go:216–226  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
216func 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:

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected