class MGit::CheckoutCommand
Public Instance Methods
arity()
click to toggle source
# File lib/mgit/commands/checkout.rb, line 14 def arity [1, 2] end
description()
click to toggle source
# File lib/mgit/commands/checkout.rb, line 22 def description 'checkout commit object in all repositories that have it' end
execute(args)
click to toggle source
# 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
usage()
click to toggle source
# File lib/mgit/commands/checkout.rb, line 18 def usage 'checkout [additional git args] <commit-sha/obj>' end
Private Instance Methods
checkout_all()
click to toggle source
# File lib/mgit/commands/checkout.rb, line 35 def checkout_all repos.each do |repo| begin if repo.dirty? pwarn "Skipping repository #{repo.name} as it is dirty." next end repo.in_repo { System.git("checkout -q #{@git_args || ''} #{@commit}") } pinfo "Switched to #{@commit} in repository #{repo.name}." rescue GitError perror "Failed to checkout #{@commit} in repository #{repo.name}." end end end
repos()
click to toggle source
# File lib/mgit/commands/checkout.rb, line 31 def repos @rs ||= Registry.select { |r| r.has_commit?(@commit) } end