(client *http.Client, repo ghrepo.Interface, pr *api.PullRequest)
| 561 | } |
| 562 | |
| 563 | func 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 | |
| 616 | type NotFoundError struct { |
| 617 | error |
no test coverage detected