From 0c3ac8734558232c5287ea737edfbe5a3ab4f290 Mon Sep 17 00:00:00 2001 From: David Rodriguez Date: Sat, 9 Oct 2021 11:29:11 +0200 Subject: [PATCH] [rubygems/rubygems] Show a warning in `bundle info` if gem has been deleted https://github.com/rubygems/rubygems/commit/ff86cd7dd2 --- lib/bundler/cli/info.rb | 11 +++++++++-- spec/bundler/commands/info_spec.rb | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb index bf0f85d3eb..00140e3bd1 100644 --- a/lib/bundler/cli/info.rb +++ b/lib/bundler/cli/info.rb @@ -55,8 +55,10 @@ module Bundler def print_gem_info(spec) metadata = spec.metadata + name = spec.name + path = spec.full_gem_path gem_info = String.new - gem_info << " * #{spec.name} (#{spec.version}#{spec.git_version})\n" + gem_info << " * #{name} (#{spec.version}#{spec.git_version})\n" gem_info << "\tSummary: #{spec.summary}\n" if spec.summary gem_info << "\tHomepage: #{spec.homepage}\n" if spec.homepage gem_info << "\tDocumentation: #{metadata["documentation_uri"]}\n" if metadata.key?("documentation_uri") @@ -66,8 +68,13 @@ module Bundler gem_info << "\tChangelog: #{metadata["changelog_uri"]}\n" if metadata.key?("changelog_uri") gem_info << "\tBug Tracker: #{metadata["bug_tracker_uri"]}\n" if metadata.key?("bug_tracker_uri") gem_info << "\tMailing List: #{metadata["mailing_list_uri"]}\n" if metadata.key?("mailing_list_uri") - gem_info << "\tPath: #{spec.full_gem_path}\n" + gem_info << "\tPath: #{path}\n" gem_info << "\tDefault Gem: yes" if spec.respond_to?(:default_gem?) && spec.default_gem? + + unless File.directory?(path) + return Bundler.ui.warn "The gem #{name} has been deleted. Gemspec information is still available though:\n#{gem_info}" + end + Bundler.ui.info gem_info end end diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb index 29cac94057..518f93511a 100644 --- a/spec/bundler/commands/info_spec.rb +++ b/spec/bundler/commands/info_spec.rb @@ -66,6 +66,10 @@ RSpec.describe "bundle info" do bundle "info rail --path" expect(err).to match(/The gem rails has been deleted/i) expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s) + + bundle "info rails" + expect(err).to match(/The gem rails has been deleted/i) + expect(err).to match(default_bundle_path("gems", "rails-2.3.2").to_s) end context "given a default gem shippped in ruby", :ruby_repo do