我如何通过github API获取所有回购请求请求的列表? [英] How can I get a list of all pull requests for a repo through the github API?

查看:119
本文介绍了我如何通过github API获取所有回购请求请求的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过github API获取回购中所有拉取请求的列表.

I want to obtain a list of all pull requests on a repo through the github API.

我已按照 http://developer.github.com/v3/pulls中的说明进行操作/,但是当我查询/repos/:owner/:repo/pulls时,它始终返回的拉取请求少于网站上显示的拉取请求.

I've followed the instructions at http://developer.github.com/v3/pulls/ but when I query /repos/:owner/:repo/pulls it's consistently returning fewer pull requests than displayed on the website.

例如,当我查询torvalds/linux仓库时,我收到9个打开请求请求(网站上有14个请求).如果我添加?state=closed,则会得到11个不同的关闭请求请求集(该网站显示大约20个).

For example, when I query the torvalds/linux repo I get 9 open pull requests (there are 14 on the website). If I add ?state=closed I get a different set of 11 closed pull requests (the website shows around 20).

有人知道这种差异发生的地方吗?是否有办法通过API获取有关回购请求请求的完整列表?

Does anyone know where this discrepancy arises, and if there's any way to get a complete list of pull requests for a repo through the API?

推荐答案

您可以通过变量state获取所有拉取请求(关闭,打开,合并).

You can get all pull requests (closed, opened, merged) through the variable state.

只需在GET查询中设置state=all,就像这样->

Just set state=all in the GET query, like this->

https://api.github.com/repos/:owner/:repo/pulls?state=all

有关更多信息:在 https://developer上查看Parameters表. github.com/v3/pulls/#list-pull-requests

根据TomášVotruba的评论:

As per Tomáš Votruba's comment:

"per_page = 30"的默认值.最大值为per_page = 100.要获得100多个结果,您需要将其称为多个Itmes:& page = 1",& page = 2" ...

the default value for, "per_page=30". The maximum is per_page=100. To get more than 100 results, you need to call it multiple itmes: "&page=1", "&page=2"...

这篇关于我如何通过github API获取所有回购请求请求的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆