Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pr list --search and --author flags #3294

Merged
merged 7 commits into from Mar 25, 2021
Merged

Add pr list --search and --author flags #3294

merged 7 commits into from Mar 25, 2021

Conversation

mislav
Copy link
Contributor

@mislav mislav commented Mar 24, 2021

This adds search functionality to pr list to complement issue list --search.

Since the search backend is now easily available through code, this also adds support for --author filter for compatibility with issue list #2628 /cc @GeorgeMac

Followup to #3196 /cc @g14a

Fixes #452, ref. #641

@mislav mislav requested a review from a team March 24, 2021 16:09
@mislav mislav added this to Backlog 🗒 in The GitHub CLI via automation Mar 24, 2021
@mislav mislav moved this from Backlog 🗒 to Needs review 🤔 in The GitHub CLI Mar 24, 2021
@GeorgeMac
Copy link

Thanks for looping me in @mislav 🙇

The GitHub CLI automation moved this from Needs review 🤔 to Needs to be merged 🎉 Mar 24, 2021
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 Nice work! I think searching for issues and prs is going to be a very popular feature.

q.SetType(githubsearch.PullRequest)
q.InRepository(ghrepo.FullName(repo))
q.AddQuery(filters.Search)
q.SortBy(githubsearch.CreatedAt, githubsearch.Desc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this override any sort parameter the user might have specified in filters.Search?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great question. Any user's query will always be appended at the end, so their own sort:* directive would override this implicit sort: directive after ElasticSearch parses it. However, after some thought, I decided that since sort:created-desc is already the default for issue search, it doesn't really need to be explicitly specified here. I'll remove it 👍

@@ -153,6 +153,34 @@ type FilterOptions struct {
Search string
}

func (opts *FilterOptions) IsDefault() bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much cleaner!

This is the default sort mode for issues, so it's not needed to
explicitly set it. Furthermore, the user can specify their own sort mode
through the `--search` option.
@mislav mislav merged commit 5aac191 into trunk Mar 25, 2021
The GitHub CLI automation moved this from Needs to be merged 🎉 to Pending Release 🥚 Mar 25, 2021
@mislav mislav deleted the pr-search branch March 25, 2021 13:13
@github-actions github-actions bot moved this from Pending Release 🥚 to Done 💤 in The GitHub CLI Mar 30, 2021
@Zayanusman221

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
The GitHub CLI
  
Done 💤
Development

Successfully merging this pull request may close these issues.

Add a search command to gh issue and gh pr
5 participants