首页 > 解决方案 > Github:如何列出问题的里程碑更新

问题描述

如何为特定工单列出当前里程碑及其先前分配的里程碑(如果适用)(+ 每个里程碑更新的日期)?我签入了 github API ( https://developer.github.com/v3/issues/#get-a-single-issue ),我可以提取当前里程碑,但不能提取之前分配的里程碑(如果它们存在)。任何想法 ?

谢谢,

标签: githubgithub-api

解决方案


您可以使用问题事件 API。为了测试这一点,我去了一个测试问题,并且:

  1. 添加里程碑new
  2. 添加里程碑two

在使用该端点查询 API 后,我得到了三个事件,两个带有 typemilestoned和一个demilestoned。端点允许您过滤这些事件,专门用于消除非常活跃的问题上的噪音。这是回复的示例(带有混淆数据)

[
  {
    "id": 2193329921,  
    "url": "https://api.github.com/repos/myOrg/myRepo/issues/events/2193329921",
    "actor": {
      "login": "myuser",
      "id": 1192590,
      "node_id": "MDQ6VXNlcjExOTI1OTA=",    
      "gravatar_id": "",
      "url": "https://api.github.com/users/myuser",
      "html_url": "https://github.com/myuser",
      "followers_url": "https://api.github.com/users/myuser/followers",
      "following_url": "https://api.github.com/users/myuser/following{/other_user}",
      "gists_url": "https://api.github.com/users/myuser/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/myuser/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/myuser/subscriptions",
      "organizations_url": "https://api.github.com/users/myuser/orgs",
      "repos_url": "https://api.github.com/users/myuser/repos",
      "events_url": "https://api.github.com/users/myuser/events{/privacy}",
      "received_events_url": "https://api.github.com/users/myuser/received_events",
      "type": "User",
      "site_admin": true
    },
    "event": "milestoned",
    "commit_id": null,
    "commit_url": null,
    "created_at": "2019-03-11T09:42:00Z",
    "milestone": {
      "title": "new"
    }
  },
  {
    "id": 2193330104,    
    "url": "https://api.github.com/repos/myOrg/myRepo/issues/events/2193330104",
    "actor": {
      "login": "myuser",
      "id": 1192590,  
      "url": "https://api.github.com/users/myuser",
      "html_url": "https://github.com/myuser",
      "followers_url": "https://api.github.com/users/myuser/followers",
      "following_url": "https://api.github.com/users/myuser/following{/other_user}",
      "gists_url": "https://api.github.com/users/myuser/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/myuser/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/myuser/subscriptions",
      "organizations_url": "https://api.github.com/users/myuser/orgs",
      "repos_url": "https://api.github.com/users/myuser/repos",
      "events_url": "https://api.github.com/users/myuser/events{/privacy}",
      "received_events_url": "https://api.github.com/users/myuser/received_events",
      "type": "User",
      "site_admin": true
    },
    "event": "demilestoned",
    "commit_id": null,
    "commit_url": null,
    "created_at": "2019-03-11T09:42:04Z",
    "milestone": {
      "title": "new"
    }
  },
  {
    "id": 2193330105,
    "url": "https://api.github.com/repos/myOrg/myRepo/issues/events/2193330105",
    "actor": {
      "login": "myuser",
      "url": "https://api.github.com/users/myuser",
      "html_url": "https://github.com/myuser",
      "followers_url": "https://api.github.com/users/myuser/followers",
      "following_url": "https://api.github.com/users/myuser/following{/other_user}",
      "gists_url": "https://api.github.com/users/myuser/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/myuser/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/myuser/subscriptions",
      "organizations_url": "https://api.github.com/users/myuser/orgs",
      "repos_url": "https://api.github.com/users/myuser/repos",
      "events_url": "https://api.github.com/users/myuser/events{/privacy}",
      "received_events_url": "https://api.github.com/users/myuser/received_events",
      "type": "User",
      "site_admin": true
    },
    "event": "milestoned",
    "commit_id": null,
    "commit_url": null,
    "created_at": "2019-03-11T09:42:04Z",
    "milestone": {
      "title": "second"
    }
  }
]


推荐阅读