gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:23:33 25 4
gpt4 key购买 nike

那里!

我正在使用 Github API 获取存储库中的拉取请求列表;

我的授权 token 是有效的,我从 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

我已经尝试了两个 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_

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

我在文档中发现只有参数:state、head、base、sort 和 direction。

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

最佳答案

使用 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 '.'

关于curl - 在 Github API 上按受让人或标签过滤 PullRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50808092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com