Class: Strata::CLI::SubCommands::Branch
- Inherits:
-
Thor
- Object
- Thor
- Strata::CLI::SubCommands::Branch
show all
- Includes:
- AgentMode, Guard, Output
- Defined in:
- lib/strata/cli/sub_commands/branch.rb
Constant Summary
Constants included
from Output
Output::THEME
Constants included
from Guard
Guard::ALLOWED_COMMANDS
Instance Method Summary
collapse
Methods included from AgentMode
#agent_mode?, included, #reject_agent_mode!
Methods included from Output
format, pastel, print_error, #print_error, print_hint, #print_hint, print_info, #print_info, print_status, #print_status, print_success, #print_success, print_warning, #print_warning, shell_for, thor_color
Methods included from Guard
#invoke_command
Instance Method Details
#checkout(branch_name) ⇒ Object
43
44
45
46
|
# File 'lib/strata/cli/sub_commands/branch.rb', line 43
def checkout(branch_name)
branch_name = Utils::Git.checkout_branch(branch_name)
print_success("Checked out branch '#{branch_name}'.")
end
|
#create(branch_name) ⇒ Object
37
38
39
40
|
# File 'lib/strata/cli/sub_commands/branch.rb', line 37
def create(branch_name)
branch_name = Utils::Git.create_and_checkout_branch(branch_name)
print_success("Created and checked out branch '#{branch_name}'.")
end
|
#delete ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/strata/cli/sub_commands/branch.rb', line 50
def delete
branch_id = branch_to_delete
config = CLI.config.get_for_environment(options[:environment])
validate_delete_configuration(config)
return unless confirm_branch_deletion(branch_id)
client = API::Client.new(config["server"], config["api_key"])
server_deleted = client.delete_branch(config["project_id"], branch_id)
print_warning("Branch '#{branch_id}' was not found on Strata server. Deleting local branch only.") unless server_deleted
delete_local_branch(branch_id)
print_success("Deleted branch '#{branch_id}'.")
end
|
#list ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/strata/cli/sub_commands/branch.rb', line 23
def list
config = CLI.config.get_for_environment(options[:environment])
local_branch_names = Utils::Git.local_branches
server_branches = fetch_server_branches(config)
rows = branch_rows(local_branch_names, server_branches)
if rows.empty?
print_info("No local or Strata server branches found.")
else
rows.each { |row| print_info(row) }
end
end
|