Class: Octopolo::Scripts::NewBranch
- Inherits:
-
Object
- Object
- Octopolo::Scripts::NewBranch
- Includes:
- CLIWrapper, ConfigWrapper, GitWrapper
- Defined in:
- lib/octopolo/scripts/new_branch.rb
Instance Attribute Summary collapse
-
#new_branch_name ⇒ Object
Returns the value of attribute new_branch_name.
-
#source_branch_name ⇒ Object
Returns the value of attribute source_branch_name.
Attributes included from CLIWrapper
Attributes included from GitWrapper
Attributes included from ConfigWrapper
Class Method Summary collapse
Instance Method Summary collapse
-
#default_source_branch_name ⇒ Object
Public: Provide a default value if none is given.
-
#execute ⇒ Object
Public: Perform the script.
-
#initialize(new_branch_name = nil, source_branch_name = nil) ⇒ NewBranch
constructor
A new instance of NewBranch.
Constructor Details
#initialize(new_branch_name = nil, source_branch_name = nil) ⇒ NewBranch
Returns a new instance of NewBranch.
18 19 20 21 |
# File 'lib/octopolo/scripts/new_branch.rb', line 18 def initialize(new_branch_name=nil, source_branch_name=nil) @new_branch_name = new_branch_name @source_branch_name = source_branch_name || config.deploy_branch end |
Instance Attribute Details
#new_branch_name ⇒ Object
Returns the value of attribute new_branch_name.
11 12 13 |
# File 'lib/octopolo/scripts/new_branch.rb', line 11 def new_branch_name @new_branch_name end |
#source_branch_name ⇒ Object
Returns the value of attribute source_branch_name.
12 13 14 |
# File 'lib/octopolo/scripts/new_branch.rb', line 12 def source_branch_name @source_branch_name end |
Class Method Details
.execute(new_branch_name = nil, source_branch_name = nil) ⇒ Object
14 15 16 |
# File 'lib/octopolo/scripts/new_branch.rb', line 14 def self.execute(new_branch_name=nil, source_branch_name=nil) new(new_branch_name, source_branch_name).execute end |
Instance Method Details
#default_source_branch_name ⇒ Object
Public: Provide a default value if none is given
36 37 38 |
# File 'lib/octopolo/scripts/new_branch.rb', line 36 def default_source_branch_name config.deploy_branch end |
#execute ⇒ Object
Public: Perform the script
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/octopolo/scripts/new_branch.rb', line 24 def execute raise ArgumentError unless new_branch_name if !git.reserved_branch?(new_branch_name) || cli.ask_boolean(Git::RESERVED_BRANCH_CONFIRM_MESSAGE) git.new_branch(new_branch_name, source_branch_name) else = Git::RESERVED_BRANCH_MESSAGE git.alert_reserved_branch exit 1 end end |