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

Method applyLabelFilter

pkg/workflow/filters.go:197–433  ·  view source on GitHub ↗

applyLabelFilter applies label name filter conditions for labeled/unlabeled triggers Supports "names: []string" to filter which label changes trigger the workflow

(data *WorkflowData, frontmatter map[string]any)

Source from the content-addressed store, hash-verified

195// applyLabelFilter applies label name filter conditions for labeled/unlabeled triggers
196// Supports "names: []string" to filter which label changes trigger the workflow
197func (c *Compiler) applyLabelFilter(data *WorkflowData, frontmatter map[string]any) {
198 filtersLog.Print("Applying label filter")
199
200 // Use cached On field from ParsedFrontmatter if available, otherwise fall back to map access
201 var onValue any
202 var hasOn bool
203 if data.ParsedFrontmatter != nil && data.ParsedFrontmatter.On != nil {
204 onValue = data.ParsedFrontmatter.On
205 hasOn = true
206 } else {
207 onValue, hasOn = frontmatter["on"]
208 }
209
210 // Check if there's an "on" section in the frontmatter
211 if !hasOn {
212 return
213 }
214
215 // Check if "on" is an object (not a string)
216 onMap, isOnMap := onValue.(map[string]any)
217 if !isOnMap {
218 return
219 }
220
221 // Check both issues, pull_request, and discussion sections for labeled/unlabeled with names
222 eventSections := []struct {
223 eventName string
224 eventValue any
225 eventNameStr string // For condition checks
226 }{
227 {"issues", onMap["issues"], "issues"},
228 {"pull_request", onMap["pull_request"], "pull_request"},
229 {"discussion", onMap["discussion"], "discussion"},
230 }
231
232 var labelConditions []ConditionNode
233
234 for _, section := range eventSections {
235 if section.eventValue == nil {
236 continue
237 }
238
239 // Check if the section is an object with types and names
240 sectionMap, isSectionMap := section.eventValue.(map[string]any)
241 if !isSectionMap {
242 continue
243 }
244
245 // Check for "types" field
246 typesValue, hasTypes := sectionMap["types"]
247 if !hasTypes {
248 continue
249 }
250
251 // Convert types to []string
252 var types []string
253 if typesArray, isTypesArray := typesValue.([]any); isTypesArray {
254 for _, t := range typesArray {

Callers 1

Calls 9

RenderMethod · 0.95
BuildEqualsFunction · 0.85
BuildPropertyAccessFunction · 0.85
BuildStringLiteralFunction · 0.85
BuildNotEqualsFunction · 0.85
BuildConditionTreeFunction · 0.85
RenderConditionFunction · 0.85
PrintMethod · 0.80
PrintfMethod · 0.45

Tested by

no test coverage detected