MCPcopy
hub / github.com/github/github-mcp-server / GetPullRequestDiff

Function GetPullRequestDiff

pkg/github/pullrequests.go:220–248  ·  view source on GitHub ↗
(ctx context.Context, client *github.Client, owner, repo string, pullNumber int)

Source from the content-addressed store, hash-verified

218}
219
220func 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
250func 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)

Callers 1

PullRequestReadFunction · 0.85

Calls 2

NewToolResultTextFunction · 0.92
CloseMethod · 0.80

Tested by

no test coverage detected