我使用以下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
有人知道我该怎么做吗?
使用GitHub Ruby API代替:https://github.com/pengwynn/octokit
可以使用以下代码更新拉取请求:
client.update_pull_request("<repository>", <pull_id>, <pull_title>, <pull_description>, <pull_state>)