Class: MSPRelease::MakeBranch

Inherits:
Object
  • Object
show all
Includes:
Exec::Helpers
Defined in:
lib/msp_release/make_branch.rb

Defined Under Namespace

Classes: BranchExistsError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Exec::Helpers

#exec

Constructor Details

#initialize(git, branch_name, options = {}) ⇒ MakeBranch

Returns a new instance of MakeBranch.



12
13
14
15
16
# File 'lib/msp_release/make_branch.rb', line 12

def initialize(git, branch_name, options={})
  @git = git
  @branch_name = branch_name
  @options = options
end

Instance Attribute Details

#branch_nameObject (readonly)

Returns the value of attribute branch_name.



8
9
10
# File 'lib/msp_release/make_branch.rb', line 8

def branch_name
  @branch_name
end

#gitObject (readonly)

Returns the value of attribute git.



9
10
11
# File 'lib/msp_release/make_branch.rb', line 9

def git
  @git
end

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/msp_release/make_branch.rb', line 10

def options
  @options
end

Instance Method Details

#perform!Object



18
19
20
21
22
23
24
25
# File 'lib/msp_release/make_branch.rb', line 18

def perform!
  if git.branch_exists?(branch_name)
    raise BranchExistsError, branch_name
  end

  git.create_and_switch(branch_name,
    :start_point => options[:start_point])
end