gpt4 book ai didi

github-api - 有没有什么快速的方法来获取所有打开的拉取请求的评论数

转载 作者:行者123 更新时间:2023-12-05 02:58:45 27 4
gpt4 key购买 nike

我需要在存储库的所有打开的拉取请求中查找评论数

我知道的唯一方法是从一个 repo 获取所有打开的 pull request 并迭代每个 pull request 并像这样执行调用

GET /repos/:owner/:repo/pulls/:pull_number/comments

并总结这些回应,但代价太大

我也尝试过这种方法(在一个 repo 中查找所有 PR 的评论)

GET /repos/:owner/:repo/pulls/comments

并像这样传递 state = open 作为查询参数

https://api.github.com/repos/angular/angular/pulls/comments?per_page=30&state=open

但它会返回所有拉取请求的评论

我们将不胜感激

最佳答案

使用 Github API Rest v3 ,您可以使用这样的搜索查询:

https://api.github.com/search/issues?q=is:pr%20state:open%20repo:angular/angular&per_page=100

您可以使用 GraphQL API v4使用以下查询:

{
repository(owner: "angular", name: "angular") {
pullRequests(states: OPEN, first: 100) {
nodes {
title
comments {
totalCount
}
}
}
}
}

Try it in the explorer

或者使用这样的搜索查询:

{
search(type: ISSUE, query: "is:pr state:open repo:angular/angular", first: 100) {
nodes {
... on PullRequest {
title
comments {
totalCount
}
}
}
}
}

Try it in the explorer

如果你想要评论计数和评论评论,你可以使用:

{
search(type: ISSUE, query: "is:pr state:open repo:angular/angular", first: 100) {
nodes {
... on PullRequest {
title
comments {
totalCount
}
reviews(first: 100) {
totalCount
nodes {
comments {
totalCount
}
}
}
}
}
}
}

Try it in the explorer

使用 :

repo_owner=angular
repo_name=angular
token=YOUR_TOKEN

curl -s -H "Authorization: bearer $token" -d '
{
"query": "query {repository(owner: \"'$repo_owner'\", name: \"'$repo_name'\") {pullRequests(states: OPEN, first: 100) {nodes {title comments {totalCount}}}}}"
}
' https://api.github.com/graphql

关于github-api - 有没有什么快速的方法来获取所有打开的拉取请求的评论数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58678266/

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