Class: GT::Commands::Up
- Inherits:
-
Object
- Object
- GT::Commands::Up
- Defined in:
- lib/gt/commands/up.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/up.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 top of the stack." if idx == branches.length - 1 GT::Git.checkout(branches[idx + 1]) end |