从Github API获取“从提交X关闭”?

时间:2015-06-18 19:37:51

标签: github-api

Github API有一个明确的方法来查看拉取请求是否已经关闭。例如,this pull request已关闭,我们可以确定使用an API call

然而,一些拉取请求是“从提交中关闭”,例如, here。如何使用Github API来确定拉取请求是“刚关闭”还是“从提交中关闭”?

1 个答案:

答案 0 :(得分:1)

您的示例实际上不是拉取请求,而是一个问题。您可以通过GitHub's Issue Events API查看有关问题结束的信息。

Example:

  

列出问题的事件

     

GET /repos/:owner/:repo/issues/:issue_number/events

     

响应

Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
      <https://api.github.com/resource?page=5>; rel="last"
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
[
  {
    "id": 1,
    "url": "https://api.github.com/repos/octocat/Hello-World/issues/events/1",
    "actor": {
      "login": "octocat",
      "id": 1,
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "",
      "url": "https://api.github.com/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://api.github.com/users/octocat/followers",
      "following_url": "https://api.github.com/users/octocat/following{/other_user}",
      "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
      "organizations_url": "https://api.github.com/users/octocat/orgs",
      "repos_url": "https://api.github.com/users/octocat/repos",
      "events_url": "https://api.github.com/users/octocat/events{/privacy}",
      "received_events_url": "https://api.github.com/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "event": "closed",
    "commit_id": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
    "created_at": "2011-04-14T16:00:49Z"
  }
]

请注意响应中的 commit_id 字段。