diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-09-27 16:50:36 +0200 |
---|---|---|
committer | David RodrÃguez <deivid.rodriguez@riseup.net> | 2019-09-27 16:50:36 +0200 |
commit | de54b58ae0d7d13d0b5f578c45f8cd4acfa6b40a (patch) | |
tree | c95d830d406e3c62aed46b38c29728882a10ede0 | |
parent | fea7fbd655805a039a8291ac588fb76982cb06f6 (diff) | |
download | bundler-fix_outdated_regression.tar.gz |
Fix outdated regression with groupless dependenciesfix_outdated_regression
-rw-r--r-- | lib/bundler/cli/outdated.rb | 10 | ||||
-rw-r--r-- | spec/commands/outdated_spec.rb | 33 |
2 files changed, 38 insertions, 5 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 2a2df4c26e..ae40d05021 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -82,7 +82,7 @@ module Bundler next unless gem_outdated || (current_spec.git_version != active_spec.git_version) dependency = current_dependencies[current_spec.name] - groups = nil + groups = "" if dependency && !options[:parseable] groups = dependency.groups.join(", ") end @@ -134,10 +134,10 @@ module Bundler end def header_group_message(groups) - if groups - "===== #{groups_text("Group", groups)} =====" - else + if groups.empty? "===== Without group =====" + else + "===== #{groups_text("Group", groups)} =====" end end @@ -198,7 +198,7 @@ module Bundler output_message = if options[:parseable] spec_outdated_info.to_s - elsif options_include_groups || !groups + elsif options_include_groups || groups.empty? " * #{spec_outdated_info}" else " * #{spec_outdated_info} in #{groups_text("group", groups)}" diff --git a/spec/commands/outdated_spec.rb b/spec/commands/outdated_spec.rb index a515c6a081..ae54b9d866 100644 --- a/spec/commands/outdated_spec.rb +++ b/spec/commands/outdated_spec.rb @@ -143,6 +143,39 @@ RSpec.describe "bundle outdated" do end end + describe "with --group option and outdated transitive dependencies" do + before do + update_repo2 do + build_gem "bar", %w[2.0.0] + + build_gem "bar_dependant", "7.0" do |s| + s.add_dependency "bar", "~> 2.0" + end + end + + install_gemfile <<-G + source "#{file_uri_for(gem_repo2)}" + + gem "bar_dependant", '7.0' + G + + update_repo2 do + build_gem "bar", %w[3.0.0] + end + end + + it "returns a sorted list of outdated gems" do + bundle "outdated --groups" + + expect(out).to include("===== Without group =====") + expect(out).to include("bar (newest 3.0.0, installed 2.0.0)") + + # Gem names are one per-line, between "*" and their parenthesized version. + gem_list = out.split("\n").map {|g| g[/\* (.*) \(/, 1] }.compact + expect(gem_list).to eq(gem_list.sort) + end + end + describe "with --groups option" do before do install_gemfile <<-G |