Class: Branchtree::Commands::Checkout
- Defined in:
- lib/branchtree/commands/checkout.rb
Instance Method Summary collapse
Methods inherited from Common
#load_situation, #load_tree, #pluralize
Methods included from Branchtree::Context
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/branchtree/commands/checkout.rb', line 11 def execute super situation = load_situation tree = load_tree current_branch = tree.find_branch(situation.current_branch_name) choice = prompt.select("Choose a branch to check out:") do || current_index = nil index = 1 tree.depth_first do |level, branch| .choice "#{' ' * level}#{branch.name}", branch current_index = index if branch == current_branch index += 1 end .choice "Cancel", :cancel .default(current_index) unless current_index.nil? end if choice == :cancel logger.info "Goodbye!" exit 0 end logger.debug "Checking out branch #{choice.name}." choice.checkout logger.success "Checkout successful." end |