Class: RGitFlow::Tasks::Feature::Start
- Defined in:
- lib/rgitflow/tasks/feature/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, #dependencies, #description, #name, #namespaces
Instance Method Summary collapse
-
#initialize(git) ⇒ Start
constructor
A new instance of Start.
- #run ⇒ Object protected
Methods inherited from Task
Methods included from Console
#execute, #invoke, #multi_task, #task?
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/feature/start.rb', line 7 def initialize(git) super(git, 'start', 'Start a feature branch', ['rgitflow', 'feature']) end |
Instance Method Details
#run ⇒ Object (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/feature/start.rb', line 13 def run status 'Starting feature branch...' unless @git.current_branch == RGitFlow::Config.[:develop] error 'Cannot create feature 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 feature branch:' branch = STDIN.gets.chomp end branch = [RGitFlow::Config.[:feature], 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 feature branch #{branch}!" end |