Class: GT::Commands::Down
- Inherits:
-
Object
- Object
- GT::Commands::Down
- Defined in:
- lib/gt/commands/down.rb
Class Method Summary collapse
Class Method Details
.run(_argv) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gt/commands/down.rb', line 6 def self.run(_argv) branches = GT::Stack.build_all raise GT::UserError, "No stack found. Use `gt create` to start one." if branches.length < 2 current = GT::Git.current_branch idx = branches.index(current) raise GT::UserError, "Current branch '#{current}' is not in a stack." if idx.nil? raise GT::UserError, "Already at the bottom of the stack." if idx == 0 GT::Git.checkout(branches[idx - 1]) end |