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

Function fetchRemoteExperimentDetails

pkg/cli/experiments_command.go:580–605  ·  view source on GitHub ↗

fetchRemoteExperimentDetails reads the state.json from a remote experiment branch.

(repoOverride, branchName, workflowID string)

Source from the content-addressed store, hash-verified

578
579// fetchRemoteExperimentDetails reads the state.json from a remote experiment branch.
580func fetchRemoteExperimentDetails(repoOverride, branchName, workflowID string) (*ExperimentDetails, error) {
581 experimentsLog.Printf("Fetching remote experiment details: repo=%s, branch=%s", repoOverride, branchName)
582
583 // Verify the branch exists.
584 encodedBranch := url.PathEscape(branchName)
585 checkArgs := []string{"api",
586 "repos/{owner}/{repo}/branches/" + encodedBranch,
587 "--jq", ".name",
588 "--repo", repoOverride,
589 }
590 checkCmd := workflow.ExecGH(checkArgs...)
591 if _, err := checkCmd.Output(); err != nil {
592 var exitErr *exec.ExitError
593 if errors.As(err, &exitErr) {
594 stderr := strings.TrimSpace(string(exitErr.Stderr))
595 if strings.Contains(stderr, "404") || strings.Contains(stderr, "not found") {
596 return nil, fmt.Errorf("experiment %q not found in %s", workflowID, repoOverride)
597 }
598 return nil, fmt.Errorf("failed to fetch experiment branch (exit %d): %s", exitErr.ExitCode(), stderr)
599 }
600 return nil, fmt.Errorf("failed to fetch experiment branch: %w", err)
601 }
602
603 state := readRemoteExperimentState(repoOverride, branchName)
604 return experimentDetailsFromState(workflowID, branchName, state), nil
605}
606
607// readLocalExperimentState reads state.json from a local git ref (e.g. "origin/experiments/foo").
608// Returns an empty state when the file is absent or cannot be parsed.

Callers 1

RunExperimentsAnalyzeFunction · 0.85

Calls 5

ExecGHFunction · 0.92
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected