MCPcopy Create free account
hub / github.com/cli/cli / preloadPrReviews

Function preloadPrReviews

pkg/cmd/pr/shared/finder.go:442–480  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, pr *api.PullRequest)

Source from the content-addressed store, hash-verified

440}
441
442func preloadPrReviews(httpClient *http.Client, repo ghrepo.Interface, pr *api.PullRequest) error {
443 if !pr.Reviews.PageInfo.HasNextPage {
444 return nil
445 }
446
447 type response struct {
448 Node struct {
449 PullRequest struct {
450 Reviews api.PullRequestReviews `graphql:"reviews(first: 100, after: $endCursor)"`
451 } `graphql:"...on PullRequest"`
452 } `graphql:"node(id: $id)"`
453 }
454
455 variables := map[string]any{
456 "id": githubv4.ID(pr.ID),
457 "endCursor": githubv4.String(pr.Reviews.PageInfo.EndCursor),
458 }
459
460 gql := api.NewClientFromHTTP(httpClient)
461
462 for {
463 var query response
464 err := gql.Query(repo.RepoHost(), "ReviewsForPullRequest", &query, variables)
465 if err != nil {
466 return err
467 }
468
469 pr.Reviews.Nodes = append(pr.Reviews.Nodes, query.Node.PullRequest.Reviews.Nodes...)
470 pr.Reviews.TotalCount = len(pr.Reviews.Nodes)
471
472 if !query.Node.PullRequest.Reviews.PageInfo.HasNextPage {
473 break
474 }
475 variables["endCursor"] = githubv4.String(query.Node.PullRequest.Reviews.PageInfo.EndCursor)
476 }
477
478 pr.Reviews.PageInfo.HasNextPage = false
479 return nil
480}
481
482func preloadPrComments(client *http.Client, repo ghrepo.Interface, pr *api.PullRequest) error {
483 if !pr.Comments.PageInfo.HasNextPage {

Callers 1

FindMethod · 0.85

Calls 5

NewClientFromHTTPFunction · 0.92
IDMethod · 0.65
StringMethod · 0.65
QueryMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected