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

Function preloadPrComments

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

Source from the content-addressed store, hash-verified

482}
483
484func preloadPrComments(client *http.Client, repo ghrepo.Interface, pr *api.PullRequest) error {
485 if !pr.Comments.PageInfo.HasNextPage {
486 return nil
487 }
488
489 type response struct {
490 Node struct {
491 PullRequest struct {
492 Comments api.Comments `graphql:"comments(first: 100, after: $endCursor)"`
493 } `graphql:"...on PullRequest"`
494 } `graphql:"node(id: $id)"`
495 }
496
497 variables := map[string]any{
498 "id": githubv4.ID(pr.ID),
499 "endCursor": githubv4.String(pr.Comments.PageInfo.EndCursor),
500 }
501
502 gql := api.NewClientFromHTTP(client)
503
504 for {
505 var query response
506 err := gql.Query(repo.RepoHost(), "CommentsForPullRequest", &query, variables)
507 if err != nil {
508 return err
509 }
510
511 pr.Comments.Nodes = append(pr.Comments.Nodes, query.Node.PullRequest.Comments.Nodes...)
512 pr.Comments.TotalCount = len(pr.Comments.Nodes)
513
514 if !query.Node.PullRequest.Comments.PageInfo.HasNextPage {
515 break
516 }
517 variables["endCursor"] = githubv4.String(query.Node.PullRequest.Comments.PageInfo.EndCursor)
518 }
519
520 pr.Comments.PageInfo.HasNextPage = false
521 return nil
522}
523
524func preloadPrClosingIssuesReferences(client *http.Client, repo ghrepo.Interface, pr *api.PullRequest) error {
525 if !pr.ClosingIssuesReferences.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