(ctx context.Context, client *github.Client, owner, repo string, pullNumber int)
| 218 | } |
| 219 | |
| 220 | func GetPullRequestDiff(ctx context.Context, client *github.Client, owner, repo string, pullNumber int) (*mcp.CallToolResult, error) { |
| 221 | raw, resp, err := client.PullRequests.GetRaw( |
| 222 | ctx, |
| 223 | owner, |
| 224 | repo, |
| 225 | pullNumber, |
| 226 | github.RawOptions{Type: github.Diff}, |
| 227 | ) |
| 228 | if err != nil { |
| 229 | return ghErrors.NewGitHubAPIErrorResponse(ctx, |
| 230 | "failed to get pull request diff", |
| 231 | resp, |
| 232 | err, |
| 233 | ), nil |
| 234 | } |
| 235 | |
| 236 | if resp.StatusCode != http.StatusOK { |
| 237 | body, err := io.ReadAll(resp.Body) |
| 238 | if err != nil { |
| 239 | return nil, fmt.Errorf("failed to read response body: %w", err) |
| 240 | } |
| 241 | return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get pull request diff", resp, body), nil |
| 242 | } |
| 243 | |
| 244 | defer func() { _ = resp.Body.Close() }() |
| 245 | |
| 246 | // Return the raw response |
| 247 | return utils.NewToolResultText(string(raw)), nil |
| 248 | } |
| 249 | |
| 250 | func GetPullRequestStatus(ctx context.Context, client *github.Client, owner, repo string, pullNumber int) (*mcp.CallToolResult, error) { |
| 251 | pr, resp, err := client.PullRequests.Get(ctx, owner, repo, pullNumber) |
no test coverage detected