Class: Startling::Commands::CreateBranch

Inherits:
Base
  • Object
show all
Defined in:
lib/startling/commands/create_branch.rb

Instance Attribute Summary

Attributes inherited from Base

#cli_options

Instance Method Summary collapse

Methods inherited from Base

#command_class, #handler_class, #initialize, load_commands, load_configuration, load_handlers, #print_args, #print_name_error_message, run, #to_camel_case

Constructor Details

This class inherits a constructor from Startling::Commands::Base

Instance Method Details

#branch_nameObject



24
25
26
27
# File 'lib/startling/commands/create_branch.rb', line 24

def branch_name
  abort "Branch name must be specified." if branch.empty?
  @branch_name ||= "#{branch}".gsub(/\s+/, '-')
end

#create_branchObject



15
16
17
18
# File 'lib/startling/commands/create_branch.rb', line 15

def create_branch
  puts "Creating branch #{branch_name}..."
  git.create_remote_branch(branch_name, base_branch: "origin/#{default_branch}")
end

#default_branchObject



20
21
22
# File 'lib/startling/commands/create_branch.rb', line 20

def default_branch
  repo.default_branch
end

#executeObject



6
7
8
9
# File 'lib/startling/commands/create_branch.rb', line 6

def execute
  create_branch if branch_name != git.current_branch
  branch_name
end

#repoObject



11
12
13
# File 'lib/startling/commands/create_branch.rb', line 11

def repo
  @repo ||= Github.repo(git.repo_name)
end