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

Function parsePushTrigger

pkg/workflow/trigger_parser.go:191–229  ·  view source on GitHub ↗

parsePushTrigger parses push-related triggers

(tokens []string)

Source from the content-addressed store, hash-verified

189
190// parsePushTrigger parses push-related triggers
191func parsePushTrigger(tokens []string) (*TriggerIR, error) {
192 if len(tokens) == 1 {
193 // Simple "push" trigger - leave as simple string, don't convert
194 // GitHub Actions supports simple event names as strings: on: push
195 return nil, nil
196 }
197
198 if len(tokens) >= 3 && tokens[1] == "to" {
199 // "push to <branch>"
200 branch := strings.Join(tokens[2:], " ")
201 triggerParserLog.Printf("Parsed push-to-branch trigger: branch=%s", branch)
202 return &TriggerIR{
203 Event: "push",
204 Filters: map[string]any{
205 "branches": []string{branch},
206 },
207 AdditionalEvents: map[string]any{
208 "workflow_dispatch": nil,
209 },
210 }, nil
211 }
212
213 if len(tokens) >= 3 && tokens[1] == "tags" {
214 // "push tags <pattern>"
215 pattern := strings.Join(tokens[2:], " ")
216 triggerParserLog.Printf("Parsed push-tags trigger: pattern=%s", pattern)
217 return &TriggerIR{
218 Event: "push",
219 Filters: map[string]any{
220 "tags": []string{pattern},
221 },
222 AdditionalEvents: map[string]any{
223 "workflow_dispatch": nil,
224 },
225 }, nil
226 }
227
228 return nil, fmt.Errorf("invalid push trigger format: '%s'. Expected format: 'push to <branch>' or 'push tags <pattern>'. Example: 'push to main' or 'push tags v*'", strings.Join(tokens, " "))
229}
230
231// parsePullRequestTrigger parses pull request triggers
232func parsePullRequestTrigger(tokens []string) (*TriggerIR, error) {

Callers 1

Calls 2

PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected