MCPcopy Index your code
hub / github.com/cli/cli / preloadPrChecks

Function preloadPrChecks

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

Source from the content-addressed store, hash-verified

561}
562
563func preloadPrChecks(client *http.Client, repo ghrepo.Interface, pr *api.PullRequest) error {
564 if len(pr.StatusCheckRollup.Nodes) == 0 {
565 return nil
566 }
567 statusCheckRollup := &pr.StatusCheckRollup.Nodes[0].Commit.StatusCheckRollup.Contexts
568 if !statusCheckRollup.PageInfo.HasNextPage {
569 return nil
570 }
571
572 endCursor := statusCheckRollup.PageInfo.EndCursor
573
574 type response struct {
575 Node *api.PullRequest
576 }
577
578 query := fmt.Sprintf(`
579 query PullRequestStatusChecks($id: ID!, $endCursor: String!) {
580 node(id: $id) {
581 ...on PullRequest {
582 %s
583 }
584 }
585 }`, api.StatusCheckRollupGraphQLWithoutCountByState("$endCursor"))
586
587 variables := map[string]interface{}{
588 "id": pr.ID,
589 }
590
591 apiClient := api.NewClientFromHTTP(client)
592 for {
593 variables["endCursor"] = endCursor
594 var resp response
595 err := apiClient.GraphQL(repo.RepoHost(), query, variables, &resp)
596 if err != nil {
597 return err
598 }
599
600 result := resp.Node.StatusCheckRollup.Nodes[0].Commit.StatusCheckRollup.Contexts
601 statusCheckRollup.Nodes = append(
602 statusCheckRollup.Nodes,
603 result.Nodes...,
604 )
605
606 if !result.PageInfo.HasNextPage {
607 break
608 }
609 endCursor = result.PageInfo.EndCursor
610 }
611
612 statusCheckRollup.PageInfo.HasNextPage = false
613 return nil
614}
615
616type NotFoundError struct {
617 error

Callers 1

FindMethod · 0.85

Calls 4

NewClientFromHTTPFunction · 0.92
GraphQLMethod · 0.80
RepoHostMethod · 0.65

Tested by

no test coverage detected