github - 如何使用 github API 获取 Github 拉取请求评论线程
问题描述
https://developer.github.com/v3/pulls/
我需要这样的 PR 评论
[
{
avartar : 'img_link',
author : 'MoonSupport',
description: 'dd\ntt',
},
{
avartar : 'img_link',
author : 'MoonSupport',
description: 'review1',
},
{
avartar : 'img_link',
author : 'MoonSupport',
description: 'review2',
}
]
有 API 可以工作吗?
请找到它。
解决方案
休息 API v3
使用 API v3,您可以使用以下方式获取 PR 评论
https://api.github.com/repos/OWNER/REPO_NAME/issues/NUMBER/comments
此 PR的示例:https ://api.github.com/repos/mui-org/material-ui/issues/21214/comments
您可以使用以下方式获取 PR 审查意见:
https://api.github.com/repos/OWNER/REPO_NAME/pulls/NUMBER/comments
此 PR的示例:https ://api.github.com/repos/mui-org/material-ui/pulls/21214/comments
但这不包括评论正文(与 Github Web UI 中的评论处于同一级别)。以下获取评论的正文:
https://api.github.com/repos/OWNER/REPO_NAME/pulls/NUMBER/reviews
此 PR的示例:https ://api.github.com/repos/mui-org/material-ui/pulls/21214/reviews
GraphQL API v4
使用GraphQL API获取评论、评论评论和评论正文:
{
repository(name: "material-ui", owner: "mui-org") {
pullRequest(number: 21214) {
reviews(first: 100) {
nodes {
bodyText
createdAt
author {
login
}
comments(first: 100) {
nodes {
author {
login
}
body
}
}
}
}
comments(first: 100) {
nodes {
author {
login
}
createdAt
body
}
totalCount
}
}
}
}
推荐阅读
- python - 这个表达是什么意思,为什么在任何 gan 中都使用它?
- ruby-on-rails - 在渲染中渲染?使用渲染 @product 渲染 @category
- php - PHP:尝试访问 bool 类型值的数组偏移量
- wordpress - WordPress 图片 URL 在 /wp-content 之前有一个空格
- nginx - Nginx:获取proxy_pass使用的上游URI
- apache-spark - Spark 结构化流式多种聚合选项
- java - 使用 indexOf、子字符串与模式匹配从核心 Java 中的网页中提取链接
- javascript - 在 Cypress 中测试复杂用户流程的最佳方法是什么?
- javascript - 我现在如何删除创建和附加的元素
- c# - 如何在 ASP.NET Core 3.1 中使用 protobuf-net 3