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

Function FindWorkflow

pkg/cmd/workflow/shared/shared.go:131–152  ·  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

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