Class: Startling::Commands::CreateBranch
- Inherits:
-
Base
- Object
- Base
- Startling::Commands::CreateBranch
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
Instance Method Details
#branch_name ⇒ Object
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_branch ⇒ Object
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_branch ⇒ Object
20
21
22
|
# File 'lib/startling/commands/create_branch.rb', line 20
def default_branch
repo.default_branch
end
|
#execute ⇒ Object
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
|
#repo ⇒ Object
11
12
13
|
# File 'lib/startling/commands/create_branch.rb', line 11
def repo
@repo ||= Github.repo(git.repo_name)
end
|