Method: Toolshed::Github#create_pull_request

Defined in:
lib/toolshed/github.rb

#create_pull_request(title, body, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/toolshed/github.rb', line 15

def create_pull_request(title, body, options={})
  options.merge!(@default_options)
  options.merge!({
    body: {
      title: title,
       body: body,
       head: "#{Toolshed::Client.github_username}:#{self.branch_name}",
       base: self.branched_from
    }.to_json
  })

  response = HTTParty.post("#{Toolshed::Client::GITHUB_BASE_API_URL}repos/#{Toolshed::Client.branched_from_user}/#{Toolshed::Client.branched_from_repo_name}/pulls", options).response
  response = JSON.parse(response.body)

  if (response["errors"].nil?)
    response
  else
    raise "validation errors #{response.inspect}"
  end
end