首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Github API上按受让人或标签过滤PullRequest

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

Stack Overflow用户
提问于 2018-06-12 09:26:56
回答 1查看 782关注 0票数 3

那里!

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

我的身份验证令牌有效,并且收到来自Github的有效JSON响应

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

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

,但是我也有兴趣通过用户登录过滤pull请求,就像我们在浏览器上使用它时Github所做的那样

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

两个URL我都试过了:

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

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

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

我在文档中找到了参数:状态、头、基、排序和方向。

如何使用此选项过滤拉流请求(标签或受理人)?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-12 23:45:01

使用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接口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

使用curljq

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 '.'
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50808092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档