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

Function fetchPRHeadSHA

pkg/cli/checks_command.go:198–216  ·  view source on GitHub ↗

fetchPRHeadSHA fetches the head commit SHA for a given PR.

(repoOverride string, prNumber string)

Source from the content-addressed store, hash-verified

196
197// fetchPRHeadSHA fetches the head commit SHA for a given PR.
198func fetchPRHeadSHA(repoOverride string, prNumber string) (string, error) {
199 output, err := execGHAPI(repoOverride, prNumber,
200 "api", "repos/{owner}/{repo}/pulls/"+prNumber, "--jq", ".head.sha")
201 if err != nil {
202 return "", err
203 }
204
205 sha := strings.TrimSpace(string(output))
206 if sha == "" {
207 return "", errors.New(console.FormatErrorWithSuggestions(
208 "PR #"+prNumber+" returned an empty SHA",
209 []string{
210 "Verify that PR #" + prNumber + " exists and is accessible",
211 "Check that the --repo flag points to the correct repository",
212 },
213 ))
214 }
215 return sha, nil
216}
217
218// classifyGHAPIError converts a gh API exit error into a user-friendly, pre-formatted error.
219func classifyGHAPIError(exitCode int, stderr string, prNumber string, repo string) error {

Callers 1

FetchChecksResultFunction · 0.85

Calls 2

execGHAPIFunction · 0.85

Tested by

no test coverage detected