我保留错误“ /usr/local/bin/git_flow_tools.rb:55:in`set_issue':未初始化的常量Net :: HTTP :: Patch(NameError)”
我需要这个:
require 'rubygems'
require 'net/http'
require 'net/https'
require 'uri'
require 'timeout'
require 'json'
require 'pp'
此功能失败:
def self.set_issue(user, repo, number, data)
uri = URI.parse('https://api.github.com')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == 'https'
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
path = URI.escape("/repos/#{user}/#{repo}/issues/#{number}")
req = Net::HTTP::Patch.new(path)
req['Content-Type'] = 'application/json'
req['Accept'] = 'application/json'
req['Authorization'] = 'token OAUTH-TOKEN'
req.body = data
begin
Timeout::timeout(30) { JSON.parse http.request(req).body }
rescue Exception => e
puts "Failed to contact github #{e}"
end
end
获取,投放或发布等其他方法可以正常使用。
有什么想法吗?
答案 0 :(得分:3)
尝试在要求之后添加
class Net::HTTP::Patch < Net::HTTPRequest
METHOD = 'PATCH'
REQUEST_HAS_BODY = true
RESPONSE_HAS_BODY = true
end