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

Function getRemoteWorkflowFiles

pkg/cli/list_workflows_command.go:240–274  ·  view source on GitHub ↗

getRemoteWorkflowFiles fetches the list of workflow files from a remote repository

(repoSpec, workflowPath string, verbose bool, jsonOutput bool)

Source from the content-addressed store, hash-verified

238
239// getRemoteWorkflowFiles fetches the list of workflow files from a remote repository
240func getRemoteWorkflowFiles(repoSpec, workflowPath string, verbose bool, jsonOutput bool) ([]string, error) {
241 listWorkflowsLog.Printf("Fetching remote workflow files: repoSpec=%s, path=%s", repoSpec, workflowPath)
242 // Parse repo spec: owner/repo[@ref]
243 var owner, repo, ref string
244 parts := strings.SplitN(repoSpec, "@", 2)
245 repoPart := parts[0]
246 if len(parts) == 2 {
247 ref = parts[1]
248 } else {
249 ref = "main" // default to main branch
250 }
251
252 // Parse owner/repo
253 repoParts := strings.Split(repoPart, "/")
254 if len(repoParts) != 2 {
255 return nil, fmt.Errorf("invalid repository format: %s (expected owner/repo or owner/repo@ref)", repoSpec)
256 }
257 owner = repoParts[0]
258 repo = repoParts[1]
259
260 if verbose && !jsonOutput {
261 fmt.Fprintf(os.Stderr, "Fetching workflow files from %s/%s@%s (path: %s)\n", owner, repo, ref, workflowPath)
262 }
263
264 // Use the parser package to list workflow files
265 listWorkflowsLog.Printf("Listing remote workflow files: owner=%s, repo=%s, ref=%s, path=%s", owner, repo, ref, workflowPath)
266 files, err := parser.ListWorkflowFiles(owner, repo, ref, workflowPath)
267 if err != nil {
268 listWorkflowsLog.Printf("Failed to list remote workflow files: %v", err)
269 return nil, fmt.Errorf("failed to list workflow files from %s/%s: %w", owner, repo, err)
270 }
271
272 listWorkflowsLog.Printf("Found %d remote workflow files", len(files))
273 return files, nil
274}

Callers 1

RunListWorkflowsFunction · 0.85

Calls 3

ListWorkflowFilesFunction · 0.92
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected