【问题标题】:Getting "closed from commit X" from Github API?从 Github API 获得“从提交 X 关闭”?
【发布时间】:2015-09-04 14:50:21
【问题描述】:

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

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

【问题讨论】:

    标签: github-api


    【解决方案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 字段。

    【讨论】:

      猜你喜欢
      • 2018-01-05
      • 1970-01-01
      • 1970-01-01
      • 2023-02-03
      • 2015-01-31
      • 2020-12-31
      • 2017-05-09
      • 2014-09-13
      • 2015-03-17
      相关资源
      最近更新 更多