【问题标题】:How to update a pull request through Github API如何通过 Github API 更新拉取请求
【发布时间】:2017-08-22 05:43:34
【问题描述】:

我想更新拉取请求的标题并执行以下操作来实现它:-(关注此文档https://developer.github.com/v3/pulls/#update-a-pull-request

data = {"title": "New title"}
url='https://hostname/api/v3/repos/owner/repo/pulls/80'
token = 'my-token'
headers = {'Content-type': 'application/json', 'Accept': 'application/json', 'Authorization': 'token %s' % token}
resp = requests.patch(url, data=json.dumps(data), headers=headers)

print resp.json()

我错过了什么?请帮忙。

【问题讨论】:

标签: python git github github-api


【解决方案1】:

以下内容对我有用:

import requests

token = "my-token"
url = "https://api.github.com/repos/:owner/:repo/pulls/:number"
payload = {
    "title": "New title"
}

r = requests.patch(url, auth=("username", token), json=payload)

print r.json()

【讨论】:

  • 它对您有什么作用?您的网址看起来很笼统。它没有像“github.company.com”这样的主机名?
  • 是的,这个解决方案使用 GitHub 主网站,而不是 GitHub Enterprise。
  • 好的,我正在使用 GitHub Enterprise,以及 API 的 V3。我可以使用相同的令牌通过我的代码将 cmets 添加到相同的拉取请求中。但是在更新拉取请求本身时,它不起作用。
  • 实际上,我的代码可以正常工作。我使用的是团队级别的代币,而不是个人代币。当我使用个人请求时,我可以更新我的拉取请求。后续问题是:我可以通过我的 git 令牌编辑其他人的拉取请求吗?
  • 啊,很高兴听到您找到了解决方案! :) 我认为有一个设置。如果您是维护者,那么您也许可以对其进行编辑。
猜你喜欢
  • 1970-01-01
  • 2015-02-16
  • 2018-10-15
  • 1970-01-01
  • 2017-12-29
  • 1970-01-01
  • 2020-08-12
  • 2013-06-09
  • 1970-01-01
相关资源
最近更新 更多