Sha256: e7cbabcb52876531755401d5f925df1cad087724953e29584c5cfebacd65f7da
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
# coding: utf-8 module Status module Github class PullRequest def initialize(branch) @branch = branch end def pull_request_found? !get_pull_request.select {|pull| pull["head"]["ref"] == @branch}.empty? end def create_pull_request puts "No pull request found, create one? (y/n)" answer = gets answer.chomp.downcase == "y" ? new_pull_request : abort("exit") end def new_pull_request response = post_pull_request puts response == "not found" ? response : response["url"] end def payload puts "enter a description" body = gets {:title => title, :body => body, :base => "master", :head => @branch } end def title `git log #{@branch} -1 --pretty=format:'%s'` end def get_pull_request Status::Request.new.get(pull_request_api) end def post_pull_request Status::Request.new.post(pull_request_api, payload) end def pull_request_api "/repos/#{Status.owner}/#{Status.repo}/pulls?access_token=#{Status.token}" end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
update_status-0.3.2 | lib/status/github/pull_request.rb |
update_status-0.3.1 | lib/status/github/pull_request.rb |
update_status-0.3.0 | lib/status/github/pull_request.rb |