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)
| 178 | // execGHAPI runs a gh api subcommand and returns raw output. |
| 179 | // repoOverride is appended as --repo if non-empty; context labels error messages. |
| 180 | func 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. |
| 198 | func fetchPRHeadSHA(repoOverride string, prNumber string) (string, error) { |
no test coverage detected