Class: GithubIssuesCli::Command::Pull_request
- Inherits:
-
GithubIssuesCli::Command
- Object
- Clamp::Command
- GithubIssuesCli::Command
- GithubIssuesCli::Command::Pull_request
- Defined in:
- lib/github_issues_cli/command/pull_request.rb
Instance Attribute Summary
Attributes inherited from GithubIssuesCli::Command
Instance Method Summary collapse
Methods inherited from GithubIssuesCli::Command
#authenticate, #get_git_push_target, #get_git_repo, #get_issue_number, #get_pullrequest, #get_source_branch, #get_upstream_repo, #initialize, #run
Constructor Details
This class inherits a constructor from GithubIssuesCli::Command
Instance Method Details
#execute ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/github_issues_cli/command/pull_request.rb', line 6 def execute issue_number = get_issue_number raise "Pull-request for issue ##{issue_number} already exists" if get_pullrequest(issue_number) github_repo = get_upstream_repo git_repo = get_git_repo target = get_git_push_target remote, ref = target.split('/', 2) puts git_repo.lib.command_proxy('push', [remote, "#{git_repo.current_branch}:#{ref}"]) raise 'Cannot create pull-request for non-origin remotes' unless remote == 'origin' source = @username + ':' + ref.split('/').last begin request = { :user => github_repo[:user], :repo => github_repo[:name], :base => base, :head => source, :issue => issue_number } Github::PullRequests.new.create(request) rescue Exception => e raise "Internal error: Cannot create pull-request.\n#{e.inspect}" end print 'Pull request for issue ' print bold '#' + issue_number puts ' created' end |