Class: GithubIssuesCli::Command::Checkout
- Inherits:
-
GithubIssuesCli::Command
- Object
- Clamp::Command
- GithubIssuesCli::Command
- GithubIssuesCli::Command::Checkout
- Defined in:
- lib/github_issues_cli/command/checkout.rb
Instance Attribute Summary
Attributes inherited from GithubIssuesCli::Command
Instance Method Summary collapse
Methods inherited from GithubIssuesCli::Command
#authenticate, #get_git_repo, #get_github_repo, #get_issue_number, #get_source, #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 |
# File 'lib/github_issues_cli/command/checkout.rb', line 6 def execute branch_name = 'issue-' + issue_number repo = get_git_repo source = nil if repo.lib.branches_all.map(&:first).include? branch_name repo.checkout branch_name else source = get_source issue_number if source.nil? github_repo = get_github_repo request = {:user => github_repo[:user], :repo => github_repo[:name], :number => issue_number} Github::Issues.new.get request rescue raise 'Can\'t find issue #' + issue_number repo.remote('upstream').fetch source = 'upstream/master' end repo.lib.checkout source, :new_branch => branch_name end print on_green ' ' print ' Checked out #' + issue_number print ' (' + source.split('/').first + ')' if source puts end |