0
votes

I keep the error "/usr/local/bin/git_flow_tools.rb:55:in `set_issue': uninitialized constant Net::HTTP::Patch (NameError)"

I'm require this:

require 'rubygems'
require 'net/http'
require 'net/https'
require 'uri'
require 'timeout'
require 'json'
require 'pp'

This function fail:

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

Other methods like Get, Put or Post works fine.

Any ideas?

1

1 Answers

4
votes

try to add after requirements

class Net::HTTP::Patch < Net::HTTPRequest
  METHOD = 'PATCH'
  REQUEST_HAS_BODY = true
  RESPONSE_HAS_BODY = true
end