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

Function listRun

pkg/cmd/pr/list/list.go:145–259  ·  view source on GitHub ↗
(opts *ListOptions)

Source from the content-addressed store, hash-verified

143}
144
145func listRun(opts *ListOptions) error {
146 httpClient, err := opts.HttpClient()
147 if err != nil {
148 return err
149 }
150
151 baseRepo, err := opts.BaseRepo()
152 if err != nil {
153 return err
154 }
155
156 if opts.Detector == nil {
157 opts.Detector = fd.NewCachedDetector(httpClient, baseRepo.RepoHost(), time.Hour*24)
158 }
159
160 prState := strings.ToLower(opts.State)
161 if prState == "open" && shared.QueryHasStateClause(opts.Search) {
162 prState = ""
163 }
164
165 filters := shared.FilterOptions{
166 Entity: "pr",
167 State: prState,
168 Author: opts.Author,
169 Assignee: opts.Assignee,
170 Labels: opts.Labels,
171 BaseBranch: opts.BaseBranch,
172 HeadBranch: opts.HeadBranch,
173 Search: opts.Search,
174 Draft: opts.Draft,
175 Fields: defaultFields,
176 }
177 if opts.Exporter != nil {
178 filters.Fields = opts.Exporter.Fields()
179 }
180 if opts.WebMode {
181 prListURL := ghrepo.GenerateRepoURL(baseRepo, "pulls")
182
183 // TODO advancedSearchFuture
184 // As of August 2025, the advanced issue search syntax is not supported
185 // in Pull Requests tab of repositories. When it's supported we can
186 // change the argument to true.
187 openURL, err := shared.ListURLWithQuery(prListURL, filters, false)
188 if err != nil {
189 return err
190 }
191
192 if opts.IO.IsStdoutTTY() {
193 fmt.Fprintf(opts.IO.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(openURL))
194 }
195 return opts.Browser.Browse(openURL)
196 }
197
198 listResult, err := listPullRequests(httpClient, opts.Detector, baseRepo, filters, opts.LimitResults)
199 if err != nil {
200 return err
201 }
202 if len(listResult.PullRequests) == 0 && opts.Exporter == nil {

Callers 2

runCommandFunction · 0.70
NewCmdListFunction · 0.70

Calls 15

IsDefaultMethod · 0.95
QueryHasStateClauseFunction · 0.92
GenerateRepoURLFunction · 0.92
ListURLWithQueryFunction · 0.92
DisplayURLFunction · 0.92
ListNoResultsFunction · 0.92
FullNameFunction · 0.92
ListHeaderFunction · 0.92
NewFunction · 0.92
WithHeaderFunction · 0.92
ColorForPRStateFunction · 0.92

Tested by 1

runCommandFunction · 0.56