Skip to content

Commit 01bbb15

Browse files
committed
Add pr list --search
1 parent 75cfed4 commit 01bbb15

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

pkg/cmd/issue/list/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
7878
cmd.Flags().StringVarP(&opts.Author, "author", "A", "", "Filter by author")
7979
cmd.Flags().StringVar(&opts.Mention, "mention", "", "Filter by mention")
8080
cmd.Flags().StringVarP(&opts.Milestone, "milestone", "m", "", "Filter by milestone `number` or `title`")
81-
cmd.Flags().StringVarP(&opts.Search, "search", "S", "", "Search issues with filter")
81+
cmd.Flags().StringVarP(&opts.Search, "search", "S", "", "Search issues with `query`")
82+
8283
return cmd
8384
}
8485

pkg/cmd/pr/list/http.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const fragment = `fragment pr on PullRequest {
2424
}`
2525

2626
func listPullRequests(httpClient *http.Client, repo ghrepo.Interface, filters prShared.FilterOptions, limit int) (*api.PullRequestAndTotalCount, error) {
27-
if filters.Assignee != "" {
27+
if filters.Assignee != "" || filters.Search != "" {
2828
return searchPullRequests(httpClient, repo, filters, limit)
2929
}
3030

@@ -171,6 +171,7 @@ func searchPullRequests(httpClient *http.Client, repo ghrepo.Interface, filters
171171
q := githubsearch.NewQuery()
172172
q.SetType(githubsearch.PullRequest)
173173
q.InRepository(ghrepo.FullName(repo))
174+
q.AddQuery(filters.Search)
174175
q.SortBy(githubsearch.CreatedAt, githubsearch.Desc)
175176

176177
switch filters.State {

pkg/cmd/pr/list/list.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type ListOptions struct {
2828
BaseBranch string
2929
Labels []string
3030
Assignee string
31+
Search string
3132
}
3233

3334
func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command {
@@ -40,9 +41,8 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
4041
Use: "list",
4142
Short: "List and filter pull requests in this repository",
4243
Example: heredoc.Doc(`
43-
$ gh pr list --limit 999
44-
$ gh pr list --state closed
45-
$ gh pr list --label "priority 1" --label "bug"
44+
$ gh pr list --label bug --label "priority 1"
45+
$ gh pr list --search "status:success review:required"
4646
$ gh pr list --web
4747
`),
4848
Args: cmdutil.NoArgsQuoteReminder,
@@ -67,6 +67,7 @@ func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Comman
6767
cmd.Flags().StringVarP(&opts.BaseBranch, "base", "B", "", "Filter by base branch")
6868
cmd.Flags().StringSliceVarP(&opts.Labels, "label", "l", nil, "Filter by labels")
6969
cmd.Flags().StringVarP(&opts.Assignee, "assignee", "a", "", "Filter by assignee")
70+
cmd.Flags().StringVarP(&opts.Search, "search", "S", "", "Search pull requests with `query`")
7071

7172
return cmd
7273
}
@@ -88,6 +89,7 @@ func listRun(opts *ListOptions) error {
8889
Assignee: opts.Assignee,
8990
Labels: opts.Labels,
9091
BaseBranch: opts.BaseBranch,
92+
Search: opts.Search,
9193
}
9294

9395
if opts.WebMode {

0 commit comments

Comments
 (0)