我正在使用以下github ruby api:https://github.com/peter-murach/github 我正在尝试更新拉取请求的描述,但文档似乎没有给出任何关于如何执行此操作的想法。 到目前为止,这是我的代码:
def link_github_jira
github = Github.new basic_auth: 'user:pass'
@github_jira = github.pull_requests.list '<Name>', '<reposity_name>', state: 'open'
@github_data = []
@issues = []
@github_jira.each do | x |
@github_data << x
end
@github_data.each do | x |
pull_id = x["title"].to_i
@pull_request_description = x["body"]
if pull_id.is_a?(Integer)
uri = URI.parse("http://<jira_url>/rest/api/2/issue/#{pull_id}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
request.basic_auth '<jira_user>', '<jira_pass>'
request["Content-Type"] = "application/json"
@jira_response = http.request(request)
@issues << JSON.parse(@jira_response.body)
if !@pull_request_description.include?("<jira_url>")
#add Jira link to pull description as it does not already exist
end
end
end
end
对于我如何做到这一点是否有任何想法?
答案 0 :(得分:1)
使用此GitHub Ruby API解决:https://github.com/pengwynn/octokit
可以使用以下代码更新拉取请求:
client.update_pull_request("<repository>", <pull_id>, <pull_title>, <pull_description>, <pull_state>)