MCPcopy Create free account
hub / github.com/cli/cli / FindWorkflow

Function FindWorkflow

pkg/cmd/workflow/shared/shared.go:129–150  ·  view source on GitHub ↗

FindWorkflow looks up a workflow either by numeric database ID, file name, or its Name field

(client *api.Client, repo ghrepo.Interface, workflowSelector string, states []WorkflowState)

Source from the content-addressed store, hash-verified

127
128// FindWorkflow looks up a workflow either by numeric database ID, file name, or its Name field
129func FindWorkflow(client *api.Client, repo ghrepo.Interface, workflowSelector string, states []WorkflowState) ([]Workflow, error) {
130 if workflowSelector == "" {
131 return nil, errors.New("empty workflow selector")
132 }
133
134 if _, err := strconv.Atoi(workflowSelector); err == nil || isWorkflowFile(workflowSelector) {
135 workflow, err := getWorkflowByID(client, repo, workflowSelector)
136 if err != nil {
137 var httpErr api.HTTPError
138 if errors.As(err, &httpErr) {
139 if httpErr.StatusCode == 404 {
140 httpErr.Message = fmt.Sprintf("workflow %s not found on the default branch", workflowSelector)
141 }
142 return nil, httpErr
143 }
144 return nil, err
145 }
146 return []Workflow{*workflow}, nil
147 }
148
149 return getWorkflowsByName(client, repo, workflowSelector, states)
150}
151
152func GetWorkflow(client *api.Client, repo ghrepo.Interface, workflowID int64) (*Workflow, error) {
153 return getWorkflowByID(client, repo, strconv.FormatInt(workflowID, 10))

Callers 3

TestFindWorkflowFunction · 0.85
ResolveWorkflowFunction · 0.85

Calls 3

isWorkflowFileFunction · 0.85
getWorkflowByIDFunction · 0.85
getWorkflowsByNameFunction · 0.85

Tested by 2

TestFindWorkflowFunction · 0.68