Sha256: b641680ddf544809316089b587696a4d328c6d4505562796a3142a27581be4b2

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 Bytes

Contents

require 'rest_client'
require 'json'

module Socialcast
  module Github
    def create_pull_request(username, password, branch, repo, body)
      payload = {:title => branch, :base => 'master', :head => branch, :body => body}.to_json
      begin
        HighLine.say "Creating pull request for #{branch} against master in #{repo}"
        RestClient.proxy = ENV['HTTPS_PROXY'] if ENV.has_key?('HTTPS_PROXY')
        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

4 entries across 4 versions & 1 rubygems

Version Path
socialcast-git-extensions-2.3.11 lib/socialcast-git-extensions/github.rb
socialcast-git-extensions-2.3.10 lib/socialcast-git-extensions/github.rb
socialcast-git-extensions-2.3.9 lib/socialcast-git-extensions/github.rb
socialcast-git-extensions-2.3.8 lib/socialcast-git-extensions/github.rb