MCPcopy
hub / github.com/cilium/cilium / WorkflowOwners

Method WorkflowOwners

tools/testowners/codeowners/codeowners.go:75–111  ·  view source on GitHub ↗
(includeWorkflowName bool)

Source from the content-addressed store, hash-verified

73}
74
75func (r *Ruleset) WorkflowOwners(includeWorkflowName bool) ([]string, error) {
76 var ghWorkflow string
77 // Example: cilium/cilium/.github/workflows/conformance-kind-proxy-embedded.yaml@refs/pull/37593/merge
78 ghWorkflowRef := os.Getenv("GITHUB_WORKFLOW_REF")
79 matches := ghWorkflowRegexp.FindStringSubmatch(ghWorkflowRef)
80 // here matches should either be nil (no match) or a slice with two values:
81 // the full match and the capture.
82 if len(matches) == 2 {
83 ghWorkflow = matches[1]
84 }
85
86 var owners []string
87 if ghWorkflow != "" {
88 workflowRule, err := r.Match(ghWorkflow)
89 if err == nil && (workflowRule == nil || workflowRule.Owners == nil) {
90 err = ErrNoOwners
91 }
92 if err != nil {
93 return nil, fmt.Errorf("matching workflow %s: %w", ghWorkflow, err)
94 }
95
96 owners = make([]string, 0, len(workflowRule.Owners))
97 for _, o := range workflowRule.Owners {
98 owner := o.String()
99 if _, ok := r.exclude[owner]; ok {
100 continue
101 }
102 if includeWorkflowName {
103 owners = append(owners, fmt.Sprintf("%s (%s)", owner, ghWorkflow))
104 } else {
105 owners = append(owners, owner)
106 }
107 }
108 }
109
110 return owners, nil
111}
112
113func (r *Ruleset) Owners(includeTestCase bool, scenarios ...Scenario) ([]string, error) {
114 if r == nil {

Callers

nothing calls this directly

Calls 3

StringMethod · 0.65
MatchMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected