Class: MGit::CheckoutCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/mgit/commands/checkout.rb

Instance Method Summary collapse

Methods inherited from Command

#check_arity, create, execute, instance_each, list, load_commands, register_alias, register_command, require_commands_from_directory

Methods included from Output

#perror, #pinfo, #psystem, #ptable, #pwarn

Instance Method Details

#arityObject



14
15
16
# File 'lib/mgit/commands/checkout.rb', line 14

def arity
  [1, 2]
end

#descriptionObject



22
23
24
# File 'lib/mgit/commands/checkout.rb', line 22

def description
  'checkout commit object in all repositories that have it'
end

#execute(args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/mgit/commands/checkout.rb', line 3

def execute(args)
  @git_args = args.shift if args.length == 2
  @commit = args.shift

  if repos.empty?
    perror "Couldn't find commit #{@commit} in any repository."
  else
    checkout_all
  end
end

#usageObject



18
19
20
# File 'lib/mgit/commands/checkout.rb', line 18

def usage
  'checkout [additional git args] <commit-sha/obj>'
end