简体   繁体   English

从 Github 中的某个里程碑获取问题

[英]Getting the issues from a certain milestone in Github

All I'm looking for is a way to get a list of issues for a given milestone.我正在寻找的只是一种获取给定里程碑的问题列表的方法。 It looks like Github treats milestones a bit like labels in that you can ask for the labels for an issue, but not the issues for a given label.看起来 Github 对待里程碑有点像标签,因为您可以要求问题的标签,但不能要求给定标签的问题。

I know that I can filter my issues by milestone on the Github website, but this traverses multiple pages and I wanted an easy way to see all of the issues for a milestone in a more printer friendly version.我知道我可以在 Github 网站上按里程碑过滤我的问题,但这会遍历多个页面,我想要一种简单的方法来查看一个更适合打印机的版本里程碑的所有问题。

Any tips?有小费吗?

You could use GitHub's API for this.您可以为此使用 GitHub 的 API。 See here on how to get the list of issues for a repo and notice the milestone parameter.请参阅此处了解如何获取 repo 的问题列表并注意里程碑参数。 The response you will get is a big JSON document, so you would have to create a small script to pull only the titles of the issues, or use grep, or smething like jq .您将获得的响应是​​一个大的 JSON 文档,因此您必须创建一个小脚本来仅提取问题的标题,或者使用 grep 或jq 之类的东西

Notice also that API responses are also paged , but you can set the paging to be 100 entries per page, which is usually enough.另请注意, API 响应也是分页的,但您可以将分页设置为每页 100 个条目,这通常就足够了。 If not, you would again have to create a small script to fetch all the pages (or do it manually).如果没有,您将不得不再次创建一个小脚本来获取所有页面(或手动执行)。

You can use the GraphQL API which is V4 .您可以使用V4GraphQL API and do something like:并执行以下操作:

{
  repository(owner: "X", name: "X") {
    milestone(number: X) {
      id
      issues(first: 100) {
        edges {
          node {
            id,
            title
          }
        }
      }
    }
  }
}

I was not able to find any easy methods.我找不到任何简单的方法。 This worked a treat for me:这对我来说是一种享受:

  1. brew install hub (on OSX). brew install hub (在 OSX 上)。 Hub is created by GitHub Hub由GitHub创建
  2. cd to the local repo you want to access the origin for. cd 到您要访问其源的本地存储库。
  3. hub issue -M 21 -f "%I,%t,%L,%b,%au,%as" > save_here.csv
  4. profit.利润。

Find the issue # (21 in the example above) in the URL on GitHub when you are viewing the milestone.查看里程碑时,请在 GitHub 上的 URL 中找到问题 #(上例中的 21)。
Docs for hub and in particular the format (-f) flag can be found here: https://hub.github.com/hub-issue.1.html可以在此处找到 hub 的文档,特别是格式 (-f) 标志: https : //hub.github.com/hub-issue.1.html

首先使用这个找到里程碑列表然后通过每个里程碑的里程碑编号查询这个api

Given a milestone $title in $owner/$repo , we can list the issues in this milestone using curl and jq:给定$owner/$repo的里程碑$title ,我们可以使用 curl 和 jq 列出该里程碑中的问题:

api_url="https://api.github.com/repos/$owner/$repo"
MS=$(curl -s "$api_url/milestones" | jq '.[] | select(.title == "QA")')
MS_number=$(echo "$MS" | jq .number -r)
MS_state=$(echo "$MS" | jq .state -r)

echo "Found $title milestone with state=$MS_state"
echo ""

issues=$(curl -s "$api_url/issues?milestone=$MS_number" | jq '.[].number' -r)
echo "The following issues are in the QA milestone:"
for i in $issues; do
  issue_title=$(curl -s "$api_url/issues/$i"  | jq '.title' -r)
  echo "  https://github/$owner/$repo/issues/$i - $issue_title"
done
echo ""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM