Class: RGitFlow::Tasks::Hotfix::Finish

Inherits:
Task
  • Object
show all
Defined in:
lib/rgitflow/tasks/hotfix/finish.rb

Constant Summary

Constants included from Printing

Printing::DEBUG_PREFIX, Printing::ERROR_PREFIX, Printing::INPUT_PREFIX, Printing::STATUS_PREFIX

Instance Attribute Summary

Attributes inherited from Task

#after, #before, #dependencies, #description, #name, #namespaces

Instance Method Summary collapse

Methods inherited from Task

#define

Methods included from Console

#invoke, #multi_task, #task?

Methods included from Printing

#debug, #error, #prompt, #status

Constructor Details

#initialize(git) ⇒ Finish

Returns a new instance of Finish.



7
8
9
# File 'lib/rgitflow/tasks/hotfix/finish.rb', line 7

def initialize(git)
  super(git, 'finish', 'Finish a hotfix branch', ['rgitflow', 'hotfix'])
end

Instance Method Details

#runObject (protected)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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

  @git.branch(RGitFlow::Config.options[:master]).checkout
  @git.merge branch, "merging #{branch} into #{RGitFlow::Config.options[:master]}"

  @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