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

Function findRemoteWorkflowFilenameForExperiment

pkg/cli/experiments_command.go:412–432  ·  view source on GitHub ↗

findRemoteWorkflowFilenameForExperiment lists .md files in .github/workflows/ via the GitHub API and returns the basename (without .md) of the first file whose sanitized name matches experimentName. This mirrors findWorkflowFileForExperiment for remote repos. Returns "" when the directory cannot be

(repoOverride, experimentName string)

Source from the content-addressed store, hash-verified

410// matches experimentName. This mirrors findWorkflowFileForExperiment for remote repos.
411// Returns "" when the directory cannot be listed or no match is found.
412func findRemoteWorkflowFilenameForExperiment(repoOverride, experimentName string) string {
413 args := []string{"api",
414 "repos/{owner}/{repo}/contents/.github/workflows",
415 "--jq", `[.[] | select(.name | endswith(".md")) | .name]`,
416 "--repo", repoOverride,
417 }
418 cmd := workflow.ExecGH(args...)
419 out, err := cmd.Output()
420 if err != nil {
421 experimentsLog.Printf("Failed to list remote workflow files from %s: %v", repoOverride, err)
422 return ""
423 }
424
425 var filenames []string
426 if err := json.Unmarshal(out, &filenames); err != nil {
427 experimentsLog.Printf("Failed to parse remote workflow file listing: %v", err)
428 return ""
429 }
430
431 return matchWorkflowFilenameByExperiment(filenames, experimentName)
432}
433
434// matchWorkflowFilenameByExperiment returns the basename (without .md) of the first file in
435// filenames whose sanitized name matches experimentName. Returns "" when no match is found.

Callers 1

Calls 3

ExecGHFunction · 0.92
PrintfMethod · 0.45

Tested by

no test coverage detected