class Papa::Task::Common::Finish

Public Class Methods

new() click to toggle source
# File lib/papa/task/common/finish.rb, line 12
def initialize
  check_if_build_branch_exists
  @success_branches = []
  @failed_branches = []
end

Private Instance Methods

failure_message() click to toggle source
# File lib/papa/task/common/finish.rb, line 68
def failure_message
  Helper::Output.failure "Failed to merge #{build_branch} to these branches:\n"
  info = ''
  @failed_branches.each_with_index do |branch, index|
    info << " #{index + 1}.) #{branch}\n"
  end
  Helper::Output.failure_info info
end
perform_task() click to toggle source
# File lib/papa/task/common/finish.rb, line 20
def perform_task
  @success = true
  @base_branches.each do |branch|
    runner = Runner.new(queue(branch))
    if runner.run
      @success_branches << branch
    else
      @failed_branches << branch
      @success = false
    end
  end
end
queue(branch) click to toggle source
# File lib/papa/task/common/finish.rb, line 33
def queue(branch)
  queue = [
    Command::Git::Checkout.new(build_branch),
    Command::Git::ResetHard.new('origin', build_branch),
    Command::Git::Checkout.new(branch),
    Command::Git::ResetHard.new('origin', branch),
    Command::Git::Merge.new(build_branch),
    Command::Git::Push.new('origin', branch)
  ]
  if @tag_name && branch == 'master'
    queue << Command::Git::Tag.new(@tag_name)
    queue << Command::Git::TagPush.new('origin', @tag_name)
  end
  queue
end
result() click to toggle source
# File lib/papa/task/common/finish.rb, line 49
def result
  if @success_branches.count > 0
    success_message
  end
  if @failed_branches.count > 0
    failure_message
    exit 1
  end
end
success_message() click to toggle source
# File lib/papa/task/common/finish.rb, line 59
def success_message
  Helper::Output.success "Successfully merged #{build_branch} to these branches:\n"
  info = ''
  @success_branches.each_with_index do |branch, index|
    info << " #{index + 1}.) #{branch}\n"
  end
  Helper::Output.success_info info
end