class Gem::Source::Git

def checkout # :nodoc:

:nodoc:
def checkout # :nodoc:
  cache
  return false unless File.exist? repo_cache_dir
  unless File.exist? install_dir
    system git_command, "clone", "--quiet", "--no-checkout",
           repo_cache_dir, install_dir
  end
  Dir.chdir install_dir do
    system git_command, "fetch", "--quiet", "--force", "--tags", install_dir
    success = system git_command, "reset", "--quiet", "--hard", rev_parse
    if @need_submodules
      require "open3"
      _, status = Open3.capture2e(git_command, "submodule", "update", "--quiet", "--init", "--recursive")
      success &&= status.success?
    end
    success
  end
end