那里!
我正在使用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_
但我找不到如何使用受让人或标记来过滤列表。
我在文档中找到了参数:状态、头、基、排序和方向。
如何使用此选项过滤拉流请求(标签或受理人)?
发布于 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
}
}
}
}
}
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 '.'
https://stackoverflow.com/questions/50808092
复制相似问题