Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 10

RESTv3: How to GET merged pull requests?

Solved! Go to Solution.

Hello,

 

https://developer.github.com/v3/pulls/#list-pull-requests mentions that state can be open, closed or all, however, there is no merged state.

How can I list merged pull requests only?

 

Best Regards,

Ani

9 Replies
Copilot Lvl 2
Message 2 of 10

Re: RESTv3: How to GET merged pull requests?

searching for this as well :)

Solution
Community Manager
Message 3 of 10

Re: RESTv3: How to GET merged pull requests?

The search API can search "merged pull requests" with "is:merged" operator.
 https://help.github.com/articles/searching-issues/#search-based-on-the-state-of-an-issue-or-pull-req...

 

 

I hope this helps!

Copilot Lvl 2
Message 4 of 10

Re: RESTv3: How to GET merged pull requests?

would it be easily possible to get the merged status of a branch?

Copilot Lvl 3
Message 5 of 10

Re: RESTv3: How to GET merged pull requests?

Hello,

 

Yes, this is helpful, thanks.

I've been looking into it and am almost done with what I want to do. Unfortunately, I can't find any information on how to sort by merged-asc / merged-desc via the Search API. This is possible in the web version of GitHub.

 

I've read the documentation at https://help.github.com/articles/sorting-search-results/ and https://help.github.com/articles/sorting-issues-and-pull-requests/ but it has no documentation on the aforementioned sorting on the Search API

 

The query I currently have is

/search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+merged:%3E2018-10-01&sort=merged

url: https://api.github.com/search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+merged:%3E2018-10-01&sort=me...

/search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+merged:%3E2018-10-01

url: https://api.github.com/search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+merged:%3E2018-10-01

Edit1: &sort=merged doesn't do anything, I wrongly assumed so.

 

And I want to sort by the opposite order, just like it's possible to do in the web version, as in

is:pr is:merged sort:merged-asc merged:>2018-10-01 

url: https://github.com/RPCS3/rpcs3/pulls?page=1&q=is%3Apr+is%3Amerged+sort%3Amerged-asc+merged%3A%3E2018...

 

How can I apply such sorting via the Search API?

 

Best Regards,

Ani

 

Community Manager
Message 6 of 10

Re: RESTv3: How to GET merged pull requests?

Hi @AniLeo,

 

I'm glad that helped! You can include the sort qualifier +sort:author-date-desc for descending and +sort:author-date-asc for ascending.

 

ie:

https://api.github.com/search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+sort:author-date-asc+merged:...

 

 

Best,

Andrea

Copilot Lvl 3
Message 7 of 10

Re: RESTv3: How to GET merged pull requests?

Hello,

 

Unfortunately this tag doesn't sort by merged order.

In fact, after taking a closer look, I noticed merge / closed sort it's likely not implemented. sort:merge or sort:closed doesn't do the intended sort on the web interface and on the search API it's doing nothing (the default sorting by creation date is applied).

 

For example, a small sample with (currently) 6 PRs

search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+merged:%3E2018-11-04+sort=author-date-asc

https://api.github.com/search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+merged:%3E2018-11-04+sort=au...

 

0closed_at

"2018-11-07T10:06:31Z"

1closed_at"2018-11-06T23:04:23Z"
2closed_at

"2018-11-07T12:46:52Z"

3closed_at

"2018-11-05T14:25:39Z"

4closed_at"2018-11-05T15:20:59Z"
5closed_at"2018-11-05T11:55:20Z"

 

0created_at

"2018-11-07T07:44:35Z"

1created_at"2018-11-06T22:38:51Z"
2created_at"2018-11-05T20:16:42Z"
3created_at"2018-11-03T15:19:19Z"
4created_at"2018-11-02T18:38:52Z"
5created_at"2018-11-01T10:32:03Z"

 

I already tried sort = merged, merged-asc, merged-desc, closed, closed-asc, closed-desc, none seem to make any effect.

Would it be possible to implement sorting by closed/merged date?

 

Best Regards,

Ani

Community Manager
Message 8 of 10

Re: RESTv3: How to GET merged pull requests?

Copilot Lvl 3
Message 9 of 10

Re: RESTv3: How to GET merged pull requests?

Hello,

 

I get the same output as I would get with

search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+sort:author-date-asc+merged:%3E2018-10-01

 

I thought &sort=merged did anything because on the web interface adding it ("sort: merged-asc") actually returns a different order than the default one even though it's also not the correct one.

I now realized that merge/closed datetime related sorting options are not implemented, because trying any sort that is not implemented (e.g. "sort: asdfgh") will return the same output as trying "sort: merged-asc".

 

What does work differently is

search/issues?q=repo:rpcs3/rpcs3+is:pr+is:merged+sort:author-date-asc+merged:%3E2018-10-01+sort:updated-asc

which shows the PRs ordered by the last update order.

However, this is not the effect I'm looking for, as a comment in a PR will change the last update date. I need to order by the "closed_at" parameter (close/merge datetime).

 

Best Regards,

Ani

Highlighted
Community Manager
Message 10 of 10

Re: RESTv3: How to GET merged pull requests?

Hmmm, I see what you are saying, there is a limitation the only sort orders we can use are the ones in the drop down below, I can definitely see how helpful it would be to have that option and I'm passing this feedback as a feature request.

 Screen Shot 2018-11-08 at 3.14.45 PM.png