class Startling::Commands::CreateBranch
Public Instance Methods
branch_name()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 28 def branch_name @branch_name ||= get_branch_name end
create_branch()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 19 def create_branch logger.info "Creating branch #{branch_name}..." git.create_remote_branch(branch_name, base_branch: "origin/#{default_branch}") end
default_branch()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 24 def default_branch repo.default_branch end
execute()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 8 def execute abort "Branch name, #{branch_name}, is not valid" unless valid_branch_name? create_branch if branch_name != git.current_branch branch_name end
repo()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 15 def repo @repo ||= Github.repo(git.repo_name) end
valid_branch_name?()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 32 def valid_branch_name? (branch_name != default_branch) && custom_validate_branch_name end
Private Instance Methods
branch()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 52 def branch @branch ||= if args.length > 1 args[1..-1].map(&:downcase).join('-') else ask("Enter branch name (enter for current branch): ") end end
custom_validate_branch_name()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 46 def custom_validate_branch_name return true if Startling.validate_branch_name.nil? Startling.validate_branch_name.call(branch_name) end
get_branch_name()
click to toggle source
# File lib/startling/commands/create_branch.rb, line 38 def get_branch_name if branch.empty? git.current_branch else "#{branch}".gsub(/\s+/, '-') end end