我如何才能找到接受了多少GitHub拉取请求?

时间:2014-02-12 04:36:14

标签: github github-api pull-request

有没有办法找出一个人的GitHub PR的接受率,可能使用API​​?

虽然在那个问题上,有趣的是找出我所报告的有多少问题已被关闭而且仍然是开放的,在所有回购中。

3 个答案:

答案 0 :(得分:3)

我没有看到直接获取该信息的方法。这样就可以得到GitHub Issues Events API 有了它,您可以列出回购的所有事件:

GET /repos/:owner/:repo/issues/events
https://api.github.com/repos/user/reponame/issues/events

过滤用户和事件(寻找"merged": true

答案 1 :(得分:0)

当然,有一种间接的方式来了解您所有已接受的PR请求,即 GitHub简历。是的, GitHub简历是基于GitHub活动生成用户简历的东西。

所以,去开始项目https://github.com/resume/resume.github.com,然后访问http://resume.github.io。在那里,您将看到所有已接受的PR请求列表。

注意:您需要先为项目加注星标,否则不允许生成简历。

答案 2 :(得分:0)

您还可以使用GraphQL API v4使用单个请求来获取问题总数,使用每个州的计数PR(CLOSEDOPENEDMERGED):< / p>

{
  user(login: "bertrandmartel") {
    totalPR: pullRequests {
      totalCount
    }
    openedPR: pullRequests(states: OPEN) {
      totalCount
    }
    closedPR: pullRequests(states: CLOSED) {
      totalCount
    }
    mergedPR: pullRequests(states: MERGED) {
      totalCount
    }
    totalIssues: issues {
      totalCount
    }
    openedIssues: issues(states: OPEN) {
      totalCount
    }
    closedIssues: issues(states: CLOSED) {
      totalCount
    }
  }
}

Try it in the explorer

,它会为您提供如下结果:

{
  "data": {
    "user": {
      "totalPR": {
        "totalCount": 17
      },
      "openedPR": {
        "totalCount": 4
      },
      "closedPR": {
        "totalCount": 1
      },
      "mergedPR": {
        "totalCount": 12
      },
      "totalIssues": {
        "totalCount": 80
      },
      "openedIssues": {
        "totalCount": 7
      },
      "closedIssues": {
        "totalCount": 73
      }
    }
  }
}