(ctx context.Context, client *github.Client, owner, repo string, pullNumber int, pagination PaginationParams)
| 387 | } |
| 388 | |
| 389 | func GetPullRequestCommits(ctx context.Context, client *github.Client, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) { |
| 390 | opts := &github.ListOptions{ |
| 391 | PerPage: pagination.PerPage, |
| 392 | Page: pagination.Page, |
| 393 | } |
| 394 | commits, resp, err := client.PullRequests.ListCommits(ctx, owner, repo, pullNumber, opts) |
| 395 | if err != nil { |
| 396 | return ghErrors.NewGitHubAPIErrorResponse(ctx, |
| 397 | "failed to get pull request commits", |
| 398 | resp, |
| 399 | err, |
| 400 | ), nil |
| 401 | } |
| 402 | defer func() { _ = resp.Body.Close() }() |
| 403 | |
| 404 | if resp.StatusCode != http.StatusOK { |
| 405 | body, err := io.ReadAll(resp.Body) |
| 406 | if err != nil { |
| 407 | return nil, fmt.Errorf("failed to read response body: %w", err) |
| 408 | } |
| 409 | return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get pull request commits", resp, body), nil |
| 410 | } |
| 411 | |
| 412 | minimalCommits := convertToMinimalPullRequestCommits(commits) |
| 413 | |
| 414 | return MarshalledTextResult(minimalCommits), nil |
| 415 | } |
| 416 | |
| 417 | // GraphQL types for review threads query |
| 418 | type reviewThreadsQuery struct { |
no test coverage detected