我正在使用以下 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
有没有人对我如何做到这一点有任何想法?