从 Github API 获取 "closed from commit X"?
Getting "closed from commit X" from Github API?
Github API 有一个明确的方法来查看拉取请求是否已关闭。例如,this pull request, has been closed, and we can determine that using an API call.
但是,一些拉取请求是 "closed from a commit",例如here。如何使用 Github API 来确定拉取请求是 "closed" 还是 "closed from a commit"?
您的示例实际上不是拉取请求,而是问题。您可以通过 GitHub's Issue Events API.
查看有关关闭问题的信息
List events for an issue
GET /repos/:owner/:repo/issues/:issue_number/events
Response
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
字段。
Github API 有一个明确的方法来查看拉取请求是否已关闭。例如,this pull request, has been closed, and we can determine that using an API call.
但是,一些拉取请求是 "closed from a commit",例如here。如何使用 Github API 来确定拉取请求是 "closed" 还是 "closed from a commit"?
您的示例实际上不是拉取请求,而是问题。您可以通过 GitHub's Issue Events API.
查看有关关闭问题的信息List events for an issue
GET /repos/:owner/:repo/issues/:issue_number/events
Response
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
字段。