MCPcopy Index your code
hub / github.com/github/gh-aw / execGHAPI

Function execGHAPI

pkg/cli/checks_command.go:180–195  ·  view source on GitHub ↗

execGHAPI runs a gh api subcommand and returns raw output. repoOverride is appended as --repo if non-empty; context labels error messages.

(repoOverride string, context string, args ...string)

Source from the content-addressed store, hash-verified

178// execGHAPI runs a gh api subcommand and returns raw output.
179// repoOverride is appended as --repo if non-empty; context labels error messages.
180func execGHAPI(repoOverride string, context string, args ...string) ([]byte, error) {
181 if repoOverride != "" {
182 args = append(args, "--repo", repoOverride)
183 }
184 cmd := workflow.ExecGH(args...)
185 output, err := cmd.Output()
186 if err != nil {
187 var exitErr *exec.ExitError
188 if errors.As(err, &exitErr) {
189 stderr := strings.TrimSpace(string(exitErr.Stderr))
190 return nil, classifyGHAPIError(exitErr.ExitCode(), stderr, context, repoOverride)
191 }
192 return nil, fmt.Errorf("gh api call failed: %w", err)
193 }
194 return output, nil
195}
196
197// fetchPRHeadSHA fetches the head commit SHA for a given PR.
198func fetchPRHeadSHA(repoOverride string, prNumber string) (string, error) {

Callers 3

fetchPRHeadSHAFunction · 0.85
fetchCheckRunsFunction · 0.85
fetchCommitStatusesFunction · 0.85

Calls 3

ExecGHFunction · 0.92
classifyGHAPIErrorFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected