class RGitFlow::Tasks::Hotfix::Finish

Public Class Methods

new(git) click to toggle source
Calls superclass method RGitFlow::Tasks::Task::new
# File lib/rgitflow/tasks/hotfix/finish.rb, line 7
def initialize(git)
  super(git, 'finish', 'Finish a hotfix branch', ['rgitflow', 'hotfix'])
end

Protected Instance Methods

run() click to toggle source
# File lib/rgitflow/tasks/hotfix/finish.rb, line 13
def run
  status 'Finishing hotfix branch...'

  branch = @git.current_branch

  unless branch.start_with? RGitFlow::Config.options[:hotfix]
    error 'Cannot finish a hotfix branch unless you are in a hotfix branch'
    abort
  end

  msg = %Q("merging #{branch} into #{RGitFlow::Config
                                         .options[:master]}")

  @git.branch(RGitFlow::Config.options[:master]).checkout
  @git.merge branch

  begin
    @git.commit_all msg
  rescue
    status 'master branch is up-to-date'
  end

  @git.push
  if @git.is_remote_branch? branch
    @git.push('origin', branch, { :delete => true })
  end

  @git.branch(branch).delete

  status "Finished hotfix branch #{branch}!"
end