MCPcopy
hub / github.com/cli/cli / searchIssues

Function searchIssues

pkg/cmd/issue/list/http.go:119–219  ·  view source on GitHub ↗
(client *api.Client, detector fd.Detector, repo ghrepo.Interface, filters prShared.FilterOptions, limit int)

Source from the content-addressed store, hash-verified

117}
118
119func searchIssues(client *api.Client, detector fd.Detector, repo ghrepo.Interface, filters prShared.FilterOptions, limit int) (*api.IssuesAndTotalCount, error) {
120 if pullRequestSearchQualifierRE.MatchString(filters.Search) {
121 return nil, fmt.Errorf("cannot use pull request search qualifiers with `gh issue list`; use `gh pr list` instead")
122 }
123
124 // TODO advancedIssueSearchCleanup
125 // We won't need feature detection when GHES 3.17 support ends, since
126 // the advanced issue search is the only available search backend for
127 // issues.
128 features, err := detector.SearchFeatures()
129 if err != nil {
130 return nil, err
131 }
132
133 fragments := fmt.Sprintf("fragment issue on Issue {%s}", api.IssueGraphQL(filters.Fields))
134 query := fragments +
135 `query IssueSearch($repo: String!, $owner: String!, $type: SearchType!, $limit: Int, $after: String, $query: String!) {
136 repository(name: $repo, owner: $owner) {
137 hasIssuesEnabled
138 }
139 search(type: $type, last: $limit, after: $after, query: $query) {
140 issueCount
141 nodes { ...issue }
142 pageInfo {
143 hasNextPage
144 endCursor
145 }
146 }
147 }`
148
149 type response struct {
150 Repository struct {
151 HasIssuesEnabled bool
152 }
153 Search struct {
154 IssueCount int
155 Nodes []api.Issue
156 PageInfo struct {
157 HasNextPage bool
158 EndCursor string
159 }
160 }
161 }
162
163 perPage := min(limit, 100)
164
165 variables := map[string]interface{}{
166 "owner": repo.RepoOwner(),
167 "repo": repo.RepoName(),
168 "limit": perPage,
169 }
170
171 filters.Repo = ghrepo.FullName(repo)
172 filters.Entity = "issue"
173
174 // TODO advancedIssueSearchCleanup
175 if features.AdvancedIssueSearchAPI {
176 variables["query"] = prShared.SearchQueryBuild(filters, true)

Calls 9

IssueGraphQLFunction · 0.92
FullNameFunction · 0.92
GraphQLMethod · 0.80
minFunction · 0.70
ErrorfMethod · 0.65
SearchFeaturesMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RepoHostMethod · 0.65