class Thegarage::Gitx::Cli::StartCommand
Constants
- EXAMPLE_BRANCH_NAMES
- VALID_BRANCH_NAME_REGEX
Public Instance Methods
start(branch_name = nil)
click to toggle source
# 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
Private Instance Methods
repo_branches()
click to toggle source
# File lib/thegarage/gitx/cli/start_command.rb, line 31 def repo_branches @branch_names ||= repo.branches.each_name.map do |branch| branch.split('/').last end end
valid_new_branch_name?(branch)
click to toggle source
# File lib/thegarage/gitx/cli/start_command.rb, line 26 def valid_new_branch_name?(branch) return false if repo_branches.include?(branch) branch =~ VALID_BRANCH_NAME_REGEX end