Skip to content

Commit

Permalink
Show a warning in bundle info if gem has been deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Oct 9, 2021
1 parent 831edf1 commit ff86cd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bundler/lib/bundler/cli/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ def print_gem_path(spec)

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")
Expand All @@ -66,8 +68,13 @@ def print_gem_info(spec)
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
Expand Down
4 changes: 4 additions & 0 deletions bundler/spec/commands/info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
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
Expand Down

0 comments on commit ff86cd7

Please sign in to comment.