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

Function fetchRemoteExperiments

pkg/cli/experiments_command.go:529–560  ·  view source on GitHub ↗

fetchRemoteExperiments lists experiment branches and reads their state via the GitHub API.

(repoOverride string)

Source from the content-addressed store, hash-verified

527
528// fetchRemoteExperiments lists experiment branches and reads their state via the GitHub API.
529func fetchRemoteExperiments(repoOverride string) ([]ExperimentInfo, error) {
530 experimentsLog.Printf("Fetching remote experiment branches: repo=%s", repoOverride)
531
532 args := []string{"api", "repos/{owner}/{repo}/branches",
533 "--paginate",
534 "--jq", `[.[] | select(.name | startswith("` + experimentsBranchPrefix + `")) | .name]`,
535 "--repo", repoOverride,
536 }
537 cmd := workflow.ExecGH(args...)
538 output, err := cmd.Output()
539 if err != nil {
540 var exitErr *exec.ExitError
541 if errors.As(err, &exitErr) {
542 return nil, fmt.Errorf("failed to fetch branches (exit %d): %s", exitErr.ExitCode(), strings.TrimSpace(string(exitErr.Stderr)))
543 }
544 return nil, fmt.Errorf("failed to fetch branches: %w", err)
545 }
546
547 branchNames, err := parsePagedJSONArray[string](string(output))
548 if err != nil {
549 return nil, fmt.Errorf("failed to parse branch list: %w", err)
550 }
551
552 var experiments []ExperimentInfo
553 for _, branchName := range branchNames {
554 workflowID := strings.TrimPrefix(branchName, experimentsBranchPrefix)
555 state := readRemoteExperimentState(repoOverride, branchName)
556 experiments = append(experiments, experimentInfoFromState(workflowID, branchName, state))
557 }
558
559 return experiments, nil
560}
561
562// fetchLocalExperimentDetails reads the state.json from a local experiment branch.
563func fetchLocalExperimentDetails(branchName, workflowID string) (*ExperimentDetails, error) {

Callers 1

RunExperimentsListFunction · 0.85

Calls 5

ExecGHFunction · 0.92
experimentInfoFromStateFunction · 0.85
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected