Skip to content

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

Merged
mislav merged 7 commits intotrunkfrom
pr-search
Mar 25, 2021
Merged

Add pr list --search and --author flags#3294
mislav merged 7 commits intotrunkfrom
pr-search

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
@GeorgeMac
Copy link

Thanks for looping me in @mislav 🙇

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 👍

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
@mislav mislav deleted the pr-search branch March 25, 2021 13:13
@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

None yet

Development

Successfully merging this pull request may close these issues.

Add a search command to gh issue and gh pr

5 participants