Class: GithubTools::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/github_tools/cli.rb

Instance Method Summary collapse

Instance Method Details

#open_pull_request(id) ⇒ Object

Raises:

  • (Thor::Error)


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/github_tools/cli.rb', line 10

def open_pull_request(id)
  status = silent_run 'git status --porcelain 2>/dev/null'
  raise Thor::Error.new('You have uncommitted changes') unless status.empty?
  ENV['EDITOR'] = ask("Enter your text editor command:\n") if ENV['EDITOR'].nil?

  pull_files = GithubTools.client.pull_files(Configuration.remote, id)
  filenames = pull_files.collect(&:filename)
  silent_run "git fetch origin pull/#{id}/head:"
  run 'git checkout FETCH_HEAD', :verbose => false
  silent_run "#{ENV['EDITOR']} #{filenames.join(' ')}"
end