Shadoninja
Shadoninja

Reputation: 1526

In Github, is there a way to search for pull requests created by any author from a provided list?

For my team's weekly builds, I go through all pull requests from the company GitHub and pull out the PRs associated to my team. This requires an annoying sieving step that requires a walk-through of the company's previous week of code contribution.

I looked at the official GitHub search documentation (HERE) and found the "author" field could be used to narrow down the search in the way I want, but when I try this at https://github.com/pulls it only works on one author at a time.

Is there a way to search across a list of authors?

For a little extra context, my team operates across a large list of repos, all of which are under a blanket organization which houses all repos across the company.

Upvotes: 91

Views: 74848

Answers (5)

Flavio Wuensche
Flavio Wuensche

Reputation: 10396

Use the advanced search

Go to this page: https://github.com/search/advanced

Apply the filters like below:

enter image description here

In the results page, use the side panel filter for Pull Requests.

enter image description here

Upvotes: 3

Tim Overly
Tim Overly

Reputation: 445

This is a very similar problem that I have encountered before. To solve this problem I captured webhooks from GitHub into a database. I know this is a "larger" solution than directly querying GitHub, but I think it is more maintainable.

If you are interested I wrote up the whole process here. In this article, I use Visivo (which I helped write) to accomplish the dashboarding. It is a developer-friendly open-source CLI for creating charts. Your change would require a trivial addition to the query of an IN (names) to the base query.

If you are interested, and there are additional charts you would find valuable as part of the GitHub dashboard, you can open up an issue on the dashboard repo here.

A big benefit of capturing the data is that you can write additional queries very quickly.

Upvotes: 1

Kyle Venn
Kyle Venn

Reputation: 8078

Option 1: Using Github's Search Query Language

Explained

  • is:pr - only PRs (since Github treats Issues and PRs both as "Issues")
  • repo: - only show PRs in that repo
  • author: - only show PRs for these authors

It shows as "Issues", but the list will only include PRs. Example

Option 2: Fancy Bookmark/Alfred/Spotlight Search

You can modify the query params in the following URL to have the list of people on your team.

  • Replacing <username1,2,3,4> with your teammates Github username's.
  • Replacing <your_company> with your company URL (or removing that entirely if not on enterprise).

https://github.<your_company>.com/search?q=author%3A<username1>+author%3A<username2>+author%3A<username3>+author%3A<username4>+is%3Apr&type=Issues

Option 3: Using Github's Advanced Search UI

You can use Github's "Advanced Search" to achieve what you're looking for without needing to learn Github's query language.

You can use the fields below for filtering:

  • To filter for specific repos, use "Advanced options" -> "In these repositories"
  • To filter for specific authors, use "Issues options" -> "Opened by the author"

It uses query params under the hood, so you can generate the search with your UI and copy and paste it (to use for Option 3).

Note: You'll need to add "is:pr" to the resulting search query, no way to do that in the UI.

Upvotes: 5

T0xicCode
T0xicCode

Reputation: 4951

Make sure that you are using the full search at https://github.com/search.

Then simply add extra author: <name> fields to your query. The searching engine will OR fields. For example:

is:pr author:username1 author:username2

(Note that this only works on https://github.com/search. The search syntax on other pages, like https://github.com/pulls, is severely limited and does not support searching by multiple authors. If you try the same search on https://github.com/pulls, GitHub will simply ignore all but one author that you list.)

To limit it to repositories by a specific owner, add the user: <owner> field to the query.

Upvotes: 103

smolin
smolin

Reputation: 164

Using the route github.com/search instead of github.com/pulls is the "right" answer in some sense, but I like the format of the /pulls page better. When working in a small team my approach is to use /pulls but substitute "involves" for "author", like this (for reference, the same query using /search and "author").

You will get "extra" hits where the author is someone outside the list, but it's another trick to know. (Names in the examples picked at random from recent public PRs)

Upvotes: 13

Related Questions