我保留错误“ /usr/local/bin/git_flow_tools.rb:55:in `set_issue': uninitialized constant 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
其他方法,如Get、Put或Post工作正常。
有任何想法吗?