在GitHub提交响应中,作者和提交者之间有什么区别?

时间:2014-01-05 19:07:58

标签: git github github-api

[
  {
    "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
    "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
    "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",
        "email": "support@github.com",
        "date": "2011-04-14T16:00:49Z"
      },
      "message": "Fix all the bugs",
      "tree": {
        "url": "https://api.github.com/repos/octocat/Hello-World/tree/6dcb09b5b57875f334f61aebed695e2e4193db5e",
        "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
      }
    },
    "author": {
      "login": "octocat",
      "id": 1,
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "somehexcode",
      "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",
      "id": 1,
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "somehexcode",
      "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
    },
    "parents": [
      {
        "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
        "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e"
      }
    ]
  }
]

这是GET /repos/:owner/:repo/commits

的回复

authorcommitter之间有什么区别?

2 个答案:

答案 0 :(得分:6)

作者是编写提交中包含的代码的个人。提交者是将代码提交到存储库的个人。当使用pull-request更新存储库时,这对于识别作者和提交者是必要的。

使用pull请求时,个人会分配存储库,进行更改,然后请求将这些更改提取到原始存储库中。通常,初始存储库的个人将充当守门人,审查,批准和拒绝拉取请求。

Pro Git以这种方式描述了不同之处:

  

作者是最初写作的人,而   提交者是最后一次申请工作的人。所以,如果你   将补丁发送给项目,其中一个核心成员适用   补丁,你们两个都得到了信任---你作为作者和   核心成员作为提交者。

答案 1 :(得分:2)

我的印象是git支持的这个功能并没有反映在所有GitHub存储库中。

例如,查看Ansible / Ansible或PyGithub / PyGithub,两个字段 - 作者和提交者 - 总是相等的。

假设用户A分叉存储库R的主服务器,提交更改C并向R的网守G请求拉请求P以包括C.G合并拉请求P从而提交C是包括在R的主分支中。

现在,查看主分支R的提交,我们看到两个条目:

1提交C,作为A在他的R分支上创建。此提交具有作者和提交者用户A.

2表示拉取请求P的提交。这表示G到R的主分支中包含C的变化。此提交将用户G作为作者和提交者,尽管他没有编写任何代码。

我的猜测是,如果与git一起使用,这两个字段支持代码源标识。在某些情况下 - 如上所述 - 可能不是这种情况。因此,作者字段并不总是代表最初编写代码的人。

这有什么意义吗?如果没有,请查看上面提到的PyGithub存储库中的一些示例案例。