【问题标题】:How do I retrieve all the reviewers in the PR in a GitHub Probot如何在 GitHub Probot 中检索 PR 中的所有审阅者
【发布时间】:2019-09-02 14:05:10
【问题描述】:

如何在来自Probot 的拉取请求中检索所有审阅者?我正在使用typescript。我还在 Probot 中收听 pull_request 事件类型。我想我需要调用context.github.pullRequests.getReview 来获取审阅者列表,但是由于我是NodeJstypescript 的新手,我不确定如何调用以下函数。有输入吗?

另外,getReview 接受参数{owner:,repo:,number:, review_id:},就我而言,我只有pr_number

 getReview(
      params: Github.PullRequestsGetReviewParams,
      callback?: Github.Callback<
        Github.Response<Github.PullRequestsGetReviewResponse>
      >
    ): Promise<Github.Response<Github.PullRequestsGetReviewResponse>>;

【问题讨论】:

  • 我尝试了context.github.pullRequests.listReviewRequests(context.issue());,但这会在 PR 创建期间添加审阅者。如何获得所有审稿人(在 PR 创建期间添加、自行请求以及由其他审稿人添加等)
  • 我同意这很令人困惑。我测试了List reviews on a pull request 端点,但它只列出了请求,而不是实际完成的评论。我建议联系支持人员,这可能是一个错误,或者文档需要更新

标签: node.js typescript octokit probot


【解决方案1】:

对我们来说,它位于reviewRequestsrequestedReviewer 对象中,使用pullRequests 查询。

需要注意的一点是审阅者可能是UserTeam,因此我们需要利用扩展运算符... on User/Team 让他们获得不同的字段。

query {
  compass: repository(owner: "YourOrg", name: "YourRepo") {
    pullRequests(states: [OPEN], last: 10) {
      edges {
        node {
          title,
          updatedAt,
          url
          mergeable
          author {
            login
          },
          reviewRequests(first: 10) {
            nodes{
              requestedReviewer{
                ... on User {
                  userName: name
                  login                  
                }
                ... on Team {
                  teamName: name
                }
              },

            }
          }
        }
      }
    }
  }
}

【讨论】:

    【解决方案2】:

    正如我在上面的评论中提到的,List reviews on a pull request 不会返回评论,而是返回评论请求。

    我找不到 REST API 端点,但您可以改为发送 GraphQL 请求

        query {
            resource(url:"https://github.com/probot/probot/pull/870") {
                ... on PullRequest {
                    title
                    url
                    reviews(first: 100) {
                        nodes {
                            author {
                                login
                            }
                        }
                    }
                }
            }
        }
    

    您可以为此使用context.graphql 方法。有关其 API,请参阅 https://github.com/octokit/graphql.js。确保您使用最新版本的 Probot(当前为 9.2.4)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-21
      • 2021-06-06
      • 1970-01-01
      • 2019-02-09
      • 1970-01-01
      • 2016-02-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多