在Github API上通过受让人或标签过滤PullRequest

时间:2018-06-12 01:26:56

标签: curl github-api

有!

我正在使用Github API来获取repo上的pull请求列表;

我的身份验证令牌有效,我收到了来自Github的有效JSON回复

choice

我正在关注他们的文档:https://developer.github.com/v3/pulls/

但我也有兴趣过滤用户登录的拉取请求,就像Github在浏览器上使用时那样

示例:https://github.com/rails/rails/pulls/assigned/dhh

我已尝试过两个网址:

curl -H "Authorization: token MY_AUTH_TOKEN" https://api.github.com/repos/my_org/their_repo/pulls

https://api.github.com/repos/my_org/their_repo/pulls/assigned/_login_

但是我找不到如何使用受让人或标签过滤列表。

我在文档中找到了params:状态,头部,基础,排序和方向。

如何使用此选项(代码或受让人)过滤提取请求?

1 个答案:

答案 0 :(得分:0)

使用Github API v3

您可以使用Github Search issues API

curl -s "https://api.github.com/search/issues?q=is:open%20is:pr%20assignee:dhh%20repo:rails/rails"

或使用--data-urlencode

curl -s -G "https://api.github.com/search/issues" \
     --data-urlencode "q=is:open is:pr assignee:dhh repo:rails/rails" | \
     jq '.'

使用Github GraphQL API v4

您可以使用以下搜索查询:

{
  search(query: "is:open is:pr assignee:dhh repo:rails/rails", type: ISSUE, first: 100) {
    issueCount
    edges {
      node {
        ... on PullRequest {
          number
          createdAt
          title
          headRef {
            name
            repository {
              nameWithOwner
            }
          }
          body
        }
      }
    }
  }
}

Try it in the explorer

使用&

curl -s -H "Authorization: bearer YOUR_TOKEN" -d '
{
    "query": "query { search(query: \"is:open is:pr assignee:dhh repo:rails/rails\", type: ISSUE, first: 100) { issueCount edges { node { ... on PullRequest { number createdAt title headRef { name repository { nameWithOwner } } body } } } } }"
}
' https://api.github.com/graphql | jq '.'