class MGit::ShowCommand

Public Instance Methods

arity() click to toggle source
# File lib/mgit/commands/show.rb, line 16
def arity
  [1, 1]
end
description() click to toggle source
# File lib/mgit/commands/show.rb, line 24
def description
  'display commit object from any repository'
end
execute(args) click to toggle source
# File lib/mgit/commands/show.rb, line 3
def execute(args)
  @commit = args.shift

  case repos.size
  when 0
    perror "Couldn't find commit #{@commit} in any repository."
  when 1
    show_commit(repos.first)
  else
    show_menu
  end
end
usage() click to toggle source
# File lib/mgit/commands/show.rb, line 20
def usage
  'show <commit-sha/obj>'
end

Private Instance Methods

repos() click to toggle source
# File lib/mgit/commands/show.rb, line 32
def repos
  @rs ||= Registry.select { |r| r.has_commit?(@commit) }
end
show_commit(repo) click to toggle source
# File lib/mgit/commands/show.rb, line 36
def show_commit(repo)
  System.git("show #{@commit}", chdir: repo.path, print_stdout: true)
end
show_menu() click to toggle source
# File lib/mgit/commands/show.rb, line 40
def show_menu
  pinfo "Found commit #{@commit} in multiple repositories."
  choose do |menu|
    menu.prompt = 'Which one should be used?'
    repos.each do |r|
      menu.choice(r.name) do
        show_commit(r)
      end
    end
  end
end