MCPcopy
hub / github.com/cli/cli / FindIssuesOrPRs

Function FindIssuesOrPRs

pkg/cmd/issue/shared/lookup.go:105–134  ·  view source on GitHub ↗

FindIssuesOrPRs loads 1 or more issues or pull requests with the specified fields. If some of the fields could not be fetched by GraphQL, this returns non-nil issues and a *PartialLoadError.

(httpClient *http.Client, repo ghrepo.Interface, issueNumbers []int, fields []string)

Source from the content-addressed store, hash-verified

103// FindIssuesOrPRs loads 1 or more issues or pull requests with the specified fields. If some of the fields
104// could not be fetched by GraphQL, this returns non-nil issues and a *PartialLoadError.
105func FindIssuesOrPRs(httpClient *http.Client, repo ghrepo.Interface, issueNumbers []int, fields []string) ([]*api.Issue, error) {
106 issuesChan := make(chan *api.Issue, len(issueNumbers))
107 g := errgroup.Group{}
108 for _, num := range issueNumbers {
109 issueNumber := num
110 g.Go(func() error {
111 issue, err := FindIssueOrPR(httpClient, repo, issueNumber, fields)
112 if err != nil {
113 return err
114 }
115
116 issuesChan <- issue
117 return nil
118 })
119 }
120
121 err := g.Wait()
122 close(issuesChan)
123
124 if err != nil {
125 return nil, err
126 }
127
128 issues := make([]*api.Issue, 0, len(issueNumbers))
129 for issue := range issuesChan {
130 issues = append(issues, issue)
131 }
132
133 return issues, nil
134}
135
136func FindIssueOrPR(httpClient *http.Client, repo ghrepo.Interface, number int, fields []string) (*api.Issue, error) {
137 fieldSet := set.NewStringSet()

Callers 1

TestFindIssuesOrPRsFunction · 0.85

Calls 2

FindIssueOrPRFunction · 0.85
WaitMethod · 0.65

Tested by 1

TestFindIssuesOrPRsFunction · 0.68