那里!
我正在使用 Github API 获取存储库上的拉取请求列表;
我的身份验证令牌有效,并且我收到来自 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/
但我也对过滤用户登录的拉取请求感兴趣,就像我们在浏览器上使用它时的 Github
一样示例:https://github.com/rails/rails/pulls/assigned/dhh
我尝试了两个网址:
https://api.github.com/repos/my_org/their_repo/pulls/assigned/_login_
和
https://api.github.com/repos/my_org/their_repo/pulls?assigned=_login_
但是我找不到如何使用受让人或标签过滤列表。
我在文档中只找到了参数:状态、头部、基础、排序和方向。
如何使用此选项(标签或受让人(过滤拉取请求?
使用 Github API v3
您可以使用 Github 搜索问题 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
}
}
}
}
}
在资源管理器中试用
使用 curl & jq :
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 '.'