Sha256: fb055b9411f933dae483750a40d203232eb273a6092893a243a6c2efeb6e0341

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

require 'rest_client'
require 'json'

module Socialcast
  module Github
    def create_pull_request(username, password, branch, repo)
      payload = {:title => branch, :base => 'master', :head => branch}.to_json
      begin
        HighLine.say "Creating pull request for #{branch} against master in #{repo}"
        response = RestClient::Request.new(:url => "https://api.github.com/repos/#{repo}/pulls", :method => "POST", :user => username, :password => password, :payload => payload, :headers => {:accept => :json, :content_type => :json}).execute
        data = JSON.parse response.body
        url = data['html_url']
      rescue RestClient::Exception => e
        data = JSON.parse e.http_body
        HighLine.say "Failed to create pull request: #{data['message']}"
        false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
socialcast-git-extensions-2.3.2 lib/socialcast-git-extensions/github.rb