导出每个GitHub问题中的所有问题和所有评论

时间:2019-03-06 05:26:29

标签: curl github export-to-csv github-api issue-tracking

期望-

  1. 导出所有GitHub问题。通过标签/受让人信息的打开/关闭状态进行过滤。
  2. 发行机构应包含特定发行中的所有评论,而不应包含发行创建期间添加的第一条评论。这个很重要。我们希望将所有问题信息提取到.csv文件中。

我正在使用以下

curl -i "https://api.github.com/repos/<repo-owner>/<repo-name>/issues" -u "<user-name>" --output issueExport.txt

这给了我出口的机会,但只不过是问题中的第一条评论。如何从问题中获取所有评论?

这是输出的样子

 HTTP/1.1 200 OK
Server: GitHub.com
Date: Wed, 06 Mar 2019 05:18:01 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 9408
Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4992
X-RateLimit-Reset: 1551853081
Cache-Control: private, max-age=60, s-maxage=60
Vary: Accept, Authorization, Cookie, X-GitHub-OTP
ETag: "3dec541c82ed153bea0f2eaf14482fba"
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type
Access-Control-Allow-Origin: *
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Content-Security-Policy: default-src 'none'
X-GitHub-Request-Id: 0436:053B:3F7D1D:7C4FAE:5C7F5808

[
  {
    "url": "https://api.github.com/repos/username/RepoName/issues/3",
    "repository_url": "https://api.github.com/repos/username/RepoName",
    "labels_url": "https://api.github.com/repos/username/RepoName/issues/3/labels{/name}",
    "comments_url": "https://api.github.com/repos/username/RepoName/issues/3/comments",
    "events_url": "https://api.github.com/repos/username/RepoName/issues/3/events",
    "html_url": "https://github.com/username/RepoName/issues/3",
    "id": 417232567,
    "node_id": "MDU6SXNzdWU0MTcyMzI1Njc=",
    "number": 3,
    "title": "CEAS-345",
    "user": {
      "login": "usernameG",
      "id": 47857828,
      "node_id": "MDQ6VXNlcjQ3ODU3ODI4",
      "avatar_url": "https://avatars3.githubusercontent.com/u/47857828?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/usernameG",
      "html_url": "https://github.com/usernameG",
      "followers_url": "https://api.github.com/users/usernameG/followers",
      "following_url": "https://api.github.com/users/usernameG/following{/other_user}",
      "gists_url": "https://api.github.com/users/usernameG/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/usernameG/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/usernameG/subscriptions",
      "organizations_url": "https://api.github.com/users/usernameG/orgs",
      "repos_url": "https://api.github.com/users/usernameG/repos",
      "events_url": "https://api.github.com/users/usernameG/events{/privacy}",
      "received_events_url": "https://api.github.com/users/usernameG/received_events",
      "type": "User",
      "site_admin": false
    },
    "labels": [
      {
        "id": 1257724247,
        "node_id": "MDU6TGFiZWwxMjU3NzI0MjQ3",
        "url": "https://api.github.com/repos/username/RepoName/labels/duplicate",
        "name": "duplicate",
        "color": "cfd3d7",
        "default": true
      }
    ],
    "state": "open",
    "locked": false,
    "assignee": null,
    "assignees": [

    ],
    "milestone": null,
    "comments": 1,
    "created_at": "2019-03-05T10:43:50Z",
    "updated_at": "2019-03-05T20:41:29Z",
    "closed_at": null,
    "author_association": "COLLABORATOR",
    "body": "Remove\r\nhttps://github.com/username/RepoName/blob/9b0b6587cef4fabde769ab4633ec8b916b95aa0c/src/destructiveChangesPost.xml#L5-L8"
  },
  {
    "url": "https://api.github.com/repos/username/RepoName/issues/2",
    "repository_url": "https://api.github.com/repos/username/RepoName",
    "labels_url": "https://api.github.com/repos/username/RepoName/issues/2/labels{/name}",
    "comments_url": "https://api.github.com/repos/username/RepoName/issues/2/comments",
    "events_url": "https://api.github.com/repos/username/RepoName/issues/2/events",
    "html_url": "https://github.com/username/RepoName/issues/2",
    "id": 417197715,
    "node_id": "MDU6SXNzdWU0MTcxOTc3MTU=",
    "number": 2,
    "title": "CEAS-123",
    "user": {
      "login": "username",
      "id": 42571385,
      "node_id": "MDQ6VXNlcjQyNTcxMzg1",
      "avatar_url": "https://avatars1.githubusercontent.com/u/42571385?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/username",
      "html_url": "https://github.com/username",
      "followers_url": "https://api.github.com/users/username/followers",
      "following_url": "https://api.github.com/users/username/following{/other_user}",
      "gists_url": "https://api.github.com/users/username/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/username/subscriptions",
      "organizations_url": "https://api.github.com/users/username/orgs",
      "repos_url": "https://api.github.com/users/username/repos",
      "events_url": "https://api.github.com/users/username/events{/privacy}",
      "received_events_url": "https://api.github.com/users/username/received_events",
      "type": "User",
      "site_admin": false
    },
    "labels": [
      {
        "id": 1257724245,
        "node_id": "MDU6TGFiZWwxMjU3NzI0MjQ1",
        "url": "https://api.github.com/repos/username/RepoName/labels/bug",
        "name": "bug",
        "color": "d73a4a",
        "default": true
      }
    ],
    "state": "open",
    "locked": false,
    "assignee": {
      "login": "username",
      "id": 42571385,
      "node_id": "MDQ6VXNlcjQyNTcxMzg1",
      "avatar_url": "https://avatars1.githubusercontent.com/u/42571385?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/username",
      "html_url": "https://github.com/username",
      "followers_url": "https://api.github.com/users/username/followers",
      "following_url": "https://api.github.com/users/username/following{/other_user}",
      "gists_url": "https://api.github.com/users/username/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/username/subscriptions",
      "organizations_url": "https://api.github.com/users/username/orgs",
      "repos_url": "https://api.github.com/users/username/repos",
      "events_url": "https://api.github.com/users/username/events{/privacy}",
      "received_events_url": "https://api.github.com/users/username/received_events",
      "type": "User",
      "site_admin": false
    },
    "assignees": [
      {
        "login": "username",
        "id": 42571385,
        "node_id": "MDQ6VXNlcjQyNTcxMzg1",
        "avatar_url": "https://avatars1.githubusercontent.com/u/42571385?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/username",
        "html_url": "https://github.com/username",
        "followers_url": "https://api.github.com/users/username/followers",
        "following_url": "https://api.github.com/users/username/following{/other_user}",
        "gists_url": "https://api.github.com/users/username/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/username/subscriptions",
        "organizations_url": "https://api.github.com/users/username/orgs",
        "repos_url": "https://api.github.com/users/username/repos",
        "events_url": "https://api.github.com/users/username/events{/privacy}",
        "received_events_url": "https://api.github.com/users/username/received_events",
        "type": "User",
        "site_admin": false
      }
    ],
    "milestone": null,
    "comments": 1,
    "created_at": "2019-03-05T09:26:08Z",
    "updated_at": "2019-03-05T09:28:39Z",
    "closed_at": null,
    "author_association": "OWNER",
    "body": "Fix this - don't use constant\r\nhttps://github.com/username/RepoName/blob/c05a78485565f38c83b604d2125d24355ded1a60/src/destructiveChangesPost.xml#L2-L4"
  },
  {
    "url": "https://api.github.com/repos/username/RepoName/issues/1",
    "repository_url": "https://api.github.com/repos/username/RepoName",
    "labels_url": "https://api.github.com/repos/username/RepoName/issues/1/labels{/name}",
    "comments_url": "https://api.github.com/repos/username/RepoName/issues/1/comments",
    "events_url": "https://api.github.com/repos/username/RepoName/issues/1/events",
    "html_url": "https://github.com/username/RepoName/pull/1",
    "id": 417197484,
    "node_id": "MDExOlB1bGxSZXF1ZXN0MjU4MjQ1NDcw",
    "number": 1,
    "title": "Update destructiveChangesPost.xml",
    "user": {
      "login": "username",
      "id": 42571385,
      "node_id": "MDQ6VXNlcjQyNTcxMzg1",
      "avatar_url": "https://avatars1.githubusercontent.com/u/42571385?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/username",
      "html_url": "https://github.com/username",
      "followers_url": "https://api.github.com/users/username/followers",
      "following_url": "https://api.github.com/users/username/following{/other_user}",
      "gists_url": "https://api.github.com/users/username/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/username/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/username/subscriptions",
      "organizations_url": "https://api.github.com/users/username/orgs",
      "repos_url": "https://api.github.com/users/username/repos",
      "events_url": "https://api.github.com/users/username/events{/privacy}",
      "received_events_url": "https://api.github.com/users/username/received_events",
      "type": "User",
      "site_admin": false
    },
    "labels": [

    ],
    "state": "open",
    "locked": false,
    "assignee": null,
    "assignees": [

    ],
    "milestone": null,
    "comments": 0,
    "created_at": "2019-03-05T09:25:34Z",
    "updated_at": "2019-03-05T10:44:23Z",
    "closed_at": null,
    "author_association": "OWNER",
    "pull_request": {
      "url": "https://api.github.com/repos/username/RepoName/pulls/1",
      "html_url": "https://github.com/username/RepoName/pull/1",
      "diff_url": "https://github.com/username/RepoName/pull/1.diff",
      "patch_url": "https://github.com/username/RepoName/pull/1.patch"
    },
    "body": ""
  }
]

1 个答案:

答案 0 :(得分:0)

您必须使用List comments on an issue端点分别GET个注释,例如:

GET /repos/:owner/:repo/issues/:number/comments

希望这会有所帮助。