Class: Gitx::Cli::StartCommand

Inherits:
BaseCommand show all
Defined in:
lib/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].freeze
VALID_BRANCH_NAME_REGEX =
/^[A-Za-z0-9\-_]+$/.freeze

Instance Method Summary collapse

Methods included from Thor::Actions

#ask_editor

Instance Method Details

#start(branch_name = nil) ⇒ Object



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

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

  checkout_branch config.base_branch
  run_git_cmd 'pull'
  repo.create_branch branch_name, config.base_branch
  checkout_branch branch_name
  run_git_cmd('commit', '--allow-empty', '--message', commit_message(branch_name))
end