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

Function preloadPrChecks

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

Source from the content-addressed store, hash-verified

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

Callers 1

FindMethod · 0.85

Calls 4

NewClientFromHTTPFunction · 0.92
GraphQLMethod · 0.80
RepoHostMethod · 0.65

Tested by

no test coverage detected