Class: GT::Commands::Top

Inherits:
Object
  • Object
show all
Defined in:
lib/gt/commands/top.rb

Class Method Summary collapse

Class Method Details

.run(_argv) ⇒ Object

Raises:



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gt/commands/top.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
  top = branches.last
  raise GT::UserError, "Current branch '#{current}' is not in a stack." unless branches.include?(current)

  if current == top
    GT::UI.info("Already at the top: #{top}")
  else
    GT::Git.checkout(top)
  end
end