Class: RGitFlow::Tasks::Release::Start

Inherits:
Task
  • Object
show all
Defined in:
lib/rgitflow/tasks/release/start.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, #description, #name, #namespaces

Instance Method Summary collapse

Methods inherited from Task

#define

Methods included from Printing

#debug, #error, #prompt, #status

Constructor Details

#initialize(git) ⇒ Start

Returns a new instance of Start.



7
8
9
# File 'lib/rgitflow/tasks/release/start.rb', line 7

def initialize(git)
  super(git, 'start', 'Start a release branch', ['rgitflow', 'release'])
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
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rgitflow/tasks/release/start.rb', line 13

def run
  status 'Starting release branch...'

  unless @git.current_branch == RGitFlow::Config.options[:develop]
    error 'Cannot create release branch unless on development branch'
    abort
  end

  branch = ENV['BRANCH']

  while branch.blank?
    error 'Cannot create a branch with an empty name!'
    prompt 'Please enter a name for your release branch:'
    branch = STDIN.gets.chomp
  end

  branch = [RGitFlow::Config.options[:release], branch].join('/')

  if @git.is_local_branch? branch
    error 'Cannot create a branch that already exists locally'
    abort
  end

  if @git.is_remote_branch? branch
    error 'Cannot create a branch that already exists remotely'
    abort
  end

  @git.branch(branch).create
  @git.branch(branch).checkout

  status "Started release branch #{branch}!"
end