【问题标题】:Merge specific commit (cherrypick) via the Github API通过 Github API 合并特定的提交(cherrypick)
【发布时间】:2014-04-20 08:05:58
【问题描述】:

这里的文档:

http://developer.github.com/v3/repos/merging/

说你可以在你的 body head 中包含一个提交 SHA1,但我似乎无法让它工作。

这是我尝试发送的内容

 HTTParty.post('http://github.com/api/v3/repos/sclayton/puppet-modules/merges', :basic_auth => auth, :headers=>{'Content-Type' => "application/json"},
:body => {
"base" => "stage",
'head'=>"sha: a593765fc0861e99b4c9538e75676c55be264f01"}.to_json)

'head'=>"a593765fc0861e99b4c9538e75676c55be264f01"}.to_json

'head'=>{"sha" =>"a593765fc0861e99b4c9538e75676c55be264f01"}}.to_json)

我想知道是否有人通过 Github API 完成了合并单个提交?

【问题讨论】:

  • 您从 API 收到什么响应?此外,您链接到的文档明确指出 base 和 head 都应该是字符串。您尝试的第二件事应该起作用了。没有 API 的响应,虽然我帮不了你。

标签: github-api


【解决方案1】:

你需要使用真正的 GitHub API:

HTTParty.post(
  'https://api.github.com/repos/sclayton/puppet-modules/merges',
  :basic_auth => auth,
  :headers=>{'Content-Type' => "application/json"},
  :body => {
    "base" => "stage",
    'head'=> "a593765fc0861e99b4c9538e75676c55be264f01"
  }.to_json)

请注意 URL 的显着差异。除非您使用的是 GitHub Enterprise 实例,否则您的 URL 应始终https://api.github.com/ 开头。当然,这只是一个猜测,因为您没有提供从 GitHub 获得的响应。

【讨论】:

  • 抱歉,我们使用的是企业版 github,所以我屏蔽了网址。话虽如此,使用您的示例时来自 github 的响应是:{“message”=>“Head does not exist”}
  • 因此,您使用企业 GitHub 的事实使事情变得复杂。 一些的东西在标准 GitHub 中的企业 API 中不可用。我强烈怀疑这是其中之一。您还确定特定的提交 ('a593765...') 确实存在于 sclayton/puppet-modules 存储库中?是不是在叉子里?
  • 你是对的。在您查询特定分支的提交时的响应中,有两个 sha 响应,我抓住了错误的一个.. 正确的 sha 是第一个。谢谢。抱歉这么糟糕。
  • @seanrclayton 你并不可怕。你没有做错什么。你犯了一个错误,没有人因此而对你不满。
猜你喜欢
  • 1970-01-01
  • 2010-10-18
  • 1970-01-01
  • 2018-10-17
  • 2015-03-01
  • 2013-08-10
  • 2019-04-28
  • 2021-08-01
相关资源
最近更新 更多