MCPcopy
hub / github.com/cli/cli / preloadClosedByPullRequestsReferences

Function preloadClosedByPullRequestsReferences

pkg/cmd/issue/view/http.go:56–93  ·  view source on GitHub ↗
(client *http.Client, repo ghrepo.Interface, issue *api.Issue)

Source from the content-addressed store, hash-verified

54}
55
56func preloadClosedByPullRequestsReferences(client *http.Client, repo ghrepo.Interface, issue *api.Issue) error {
57 if !issue.ClosedByPullRequestsReferences.PageInfo.HasNextPage {
58 return nil
59 }
60
61 type response struct {
62 Node struct {
63 Issue struct {
64 ClosedByPullRequestsReferences api.ClosedByPullRequestsReferences `graphql:"closedByPullRequestsReferences(first: 100, after: $endCursor)"`
65 } `graphql:"...on Issue"`
66 } `graphql:"node(id: $id)"`
67 }
68
69 variables := map[string]interface{}{
70 "id": githubv4.ID(issue.ID),
71 "endCursor": githubv4.String(issue.ClosedByPullRequestsReferences.PageInfo.EndCursor),
72 }
73
74 gql := api.NewClientFromHTTP(client)
75
76 for {
77 var query response
78 err := gql.Query(repo.RepoHost(), "closedByPullRequestsReferences", &query, variables)
79 if err != nil {
80 return err
81 }
82
83 issue.ClosedByPullRequestsReferences.Nodes = append(issue.ClosedByPullRequestsReferences.Nodes, query.Node.Issue.ClosedByPullRequestsReferences.Nodes...)
84
85 if !query.Node.Issue.ClosedByPullRequestsReferences.PageInfo.HasNextPage {
86 break
87 }
88 variables["endCursor"] = githubv4.String(query.Node.Issue.ClosedByPullRequestsReferences.PageInfo.EndCursor)
89 }
90
91 issue.ClosedByPullRequestsReferences.PageInfo.HasNextPage = false
92 return nil
93}

Callers 1

viewRunFunction · 0.85

Calls 5

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

Tested by

no test coverage detected