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

Function GetPullRequestFiles

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

Source from the content-addressed store, hash-verified

359}
360
361func GetPullRequestFiles(ctx context.Context, client *github.Client, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) {
362 opts := &github.ListOptions{
363 PerPage: pagination.PerPage,
364 Page: pagination.Page,
365 }
366 files, resp, err := client.PullRequests.ListFiles(ctx, owner, repo, pullNumber, opts)
367 if err != nil {
368 return ghErrors.NewGitHubAPIErrorResponse(ctx,
369 "failed to get pull request files",
370 resp,
371 err,
372 ), nil
373 }
374 defer func() { _ = resp.Body.Close() }()
375
376 if resp.StatusCode != http.StatusOK {
377 body, err := io.ReadAll(resp.Body)
378 if err != nil {
379 return nil, fmt.Errorf("failed to read response body: %w", err)
380 }
381 return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get pull request files", resp, body), nil
382 }
383
384 minimalFiles := convertToMinimalPRFiles(files)
385
386 return MarshalledTextResult(minimalFiles), nil
387}
388
389func GetPullRequestCommits(ctx context.Context, client *github.Client, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) {
390 opts := &github.ListOptions{

Callers 1

PullRequestReadFunction · 0.85

Calls 3

convertToMinimalPRFilesFunction · 0.85
MarshalledTextResultFunction · 0.85
CloseMethod · 0.80

Tested by

no test coverage detected