class GitTopic::Commands::Publish

Publish command creates pull request from description.

Public Class Methods

new(client, repo, branch_name, base) click to toggle source
# File lib/git_topic/commands/publish.rb, line 9
def initialize(client, repo, branch_name, base)
  @client = client
  @repo = repo
  @branch_name = branch_name
  @base = base
end

Public Instance Methods

execute() click to toggle source
# File lib/git_topic/commands/publish.rb, line 16
def execute
  head = @branch_name
  response = create_pull_request(@repo, @base, head)
  puts response[:html_url]
rescue StandardError => ex
  STDERR.puts ex.message
end

Private Instance Methods

create_pull_request(repo, base, branch_name) click to toggle source
# File lib/git_topic/commands/publish.rb, line 26
def create_pull_request(repo, base, branch_name)
  title = load_title(branch_name)
  @client.create_pull_request(repo, base, branch_name, title)
end
load_title(head) click to toggle source
# File lib/git_topic/commands/publish.rb, line 31
def load_title(head)
  config_key = "branch.#{head}.description"
  command = "git config #{config_key}"
  _stdin, stdout, _stderr, _wait_thr = *Open3.popen3(command)
  stdout.readlines[0].chop
end