Github API-获取提交日期

问题描述

我想从Github API v3 https://developer.github.com/v3/repos/commits/中检索提交信息。除了提交日期,我得到了所有信息。

{
  "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e","sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e","node_id": "MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==","html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e","comments_url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments","commit": {
    "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e","author": {
      "name": "Monalisa Octocat","email": "support@github.com","date": "2011-04-14T16:00:49Z"
    },"committer": {
      "name": "Monalisa Octocat","message": "Fix all the bugs","tree": {
      "url": "https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e","sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
    },"comment_count": 0,"verification": {
      "verified": false,"reason": "unsigned","signature": null,"payload": null
    }
  },"author": {
    "login": "octocat","id": 1,"node_id": "MDQ6VXNlcjE=","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
  },"committer": {
    "login": "octocat","parents": [
    {
      "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e","sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
    }
  ],"stats": {
    "additions": 104,"deletions": 4,"total": 108
  },"files": [
    {
      "filename": "file1.txt","additions": 10,"deletions": 2,"changes": 12,"status": "modified","raw_url": "https://github.com/octocat/Hello-World/raw/7ca483543807a51b6079e54ac4cc392bc29ae284/file1.txt","blob_url": "https://github.com/octocat/Hello-World/blob/7ca483543807a51b6079e54ac4cc392bc29ae284/file1.txt","patch": "@@ -29,7 +29,7 @@\n....."
    }
  ]
}

我在哪里可以检索提交完成的日期?我正在使用PyGithub访问信息。提交对象(https://github.com/PyGithub/PyGithub/blob/master/github/Commit.py)中也没有此类字段。

解决方法

日期在那里,可能不是您期望的日期,因为实际上有两个日期:

    "author": {
      ...
      "date": "2011-04-14T16:00:49Z"
    },"committer": {
      ...
      "date": "2011-04-14T16:00:49Z"
    },

由于这些名称的命名方式,您可能会认为它们与创建用户的时间或某些事情有关,但实际上它们是提交的“作者”日期和“提交的日期”。

在这种情况下,两个日期相同,作者和提交者名称也相同。区别在于运行git rebasegit cherry-pick(或类似命令)时:git创建一个新的提交,但保留原始的“作者”信息; “提交者”信息将被运行rebase / cherry-pick的人以及他们这样做的时间戳所覆盖。这对于需要跟踪贡献版权的项目很重要:重新确定提交不应使维护者相信更改的创作,而应记录其参与。

您实际使用哪个日期取决于您,但是“作者”日期可能更相关。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...