Class: Thegarage::Gitx::Cli::StartCommand

Inherits:
BaseCommand show all
Defined in:
lib/thegarage/gitx/cli/start_command.rb

Constant Summary collapse

EXAMPLE_BRANCH_NAMES =
%w( api-fix-invalid-auth desktop-cleanup-avatar-markup share-form-add-edit-link )
VALID_BRANCH_NAME_REGEX =
/^[A-Za-z0-9\-_]+$/

Instance Method Summary collapse

Methods inherited from BaseCommand

#initialize

Methods included from Thor::Actions

#ask_editor, #run_cmd

Constructor Details

This class inherits a constructor from Thegarage::Gitx::Cli::BaseCommand

Instance Method Details

#start(branch_name = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/thegarage/gitx/cli/start_command.rb', line 13

def start(branch_name = nil)
  until valid_new_branch_name?(branch_name)
    branch_name = ask("What would you like to name your branch? (ex: #{EXAMPLE_BRANCH_NAMES.sample})")
  end

  checkout_branch Thegarage::Gitx::BASE_BRANCH
  run_cmd 'git pull'
  repo.create_branch branch_name, Thegarage::Gitx::BASE_BRANCH
  checkout_branch branch_name
end