Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions lib/bundler/cli/outdated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ def run
dependency = current_dependencies[current_spec.name]
groups = ""
if dependency && !options[:parseable]
groups = dependency.groups.join(", ")
groups = dependency.groups
groups = groups.sort if options_include_groups
groups = groups.join(", ")
end

outdated_gems << {
Expand All @@ -101,13 +103,11 @@ def run
}
end

relevant_outdated_gems = if options_include_groups
outdated_gems.group_by {|g| g[:groups] }.sort.flat_map do |groups, gems|
contains_group = groups.split(", ").include?(options[:group])
next unless options[:groups] || contains_group

gems
end.compact
relevant_outdated_gems = if options[:groups]
without_groups, with_groups = outdated_gems.partition {|g| g[:groups].empty? }
with_groups.group_by {|g| g[:groups] }.sort.flat_map(&:last) + without_groups
elsif options_include_groups
outdated_gems.select {|g| g[:groups].split(", ").include?(options[:group]) }
else
outdated_gems
end
Expand Down Expand Up @@ -333,8 +333,6 @@ def print_indented(matrix)

Bundler.ui.info justify(header, column_sizes)

data.sort_by! {|row| row[0] }

data.each do |row|
Bundler.ui.info justify(row, column_sizes)
end
Expand Down
84 changes: 84 additions & 0 deletions spec/commands/outdated_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,30 @@ def test_group_option(group)

expect(out).to end_with(expected_output)
end

it "returns a sorted list of outdated gems from one group spread over several group sets" do
install_gemfile <<-G
source "https://gem.repo2"

gem "weakling", "~> 0.0.1"
group :development do
gem "terranova", '8'
end
group :development, :test do
gem 'activesupport', '2.3.5'
end
G

test_group_option("development")

expected_output = <<~TABLE.strip
Gem Current Latest Requested Groups Release Date
activesupport 2.3.5 3.0 = 2.3.5 development, test
terranova 8 9 = 8 development
TABLE

expect(out).to end_with(expected_output)
end
end

describe "with --groups option and outdated transitive dependencies" do
Expand Down Expand Up @@ -267,13 +291,39 @@ def test_group_option(group)

expect(out).to end_with(expected_output)
end

it "lists the outdated gems without groups after the grouped ones" do
install_gemfile <<-G
source "https://gem.repo2"

gem "bar_dependant", '7.0'
gem "myrack_middleware"
gem "terranova", '8'
G

update_repo2 do
build_gem "terranova", "9"
end

bundle "outdated --groups", raise_on_error: false

expected_output = <<~TABLE.strip
Gem Current Latest Requested Groups Release Date
terranova 8 9 = 8 default
bar 2.0.0 3.0.0
myrack 0.9.1 1.0.0
TABLE

expect(out).to end_with(expected_output)
end
end

describe "with --groups option" do
before do
build_repo2 do
build_git "foo", path: lib_path("foo")
build_git "zebra", path: lib_path("zebra")
build_gem "zondrian", "1.2"
end

install_gemfile <<-G
Expand All @@ -284,6 +334,7 @@ def test_group_option(group)
group :development, :test do
gem 'activesupport', '2.3.5'
gem "duradura", '7.0'
gem "zondrian", '1.2'
end
G
end
Expand All @@ -298,15 +349,48 @@ def test_group_option(group)
build_gem "activesupport", "3.0"
build_gem "terranova", "9"
build_gem "duradura", "8.0"
build_gem "zondrian", "1.3"
end

bundle "outdated --groups", raise_on_error: false

expected_output = <<~TABLE.strip
Gem Current Latest Requested Groups Release Date
terranova 8 9 = 8 default
activesupport 2.3.5 3.0 = 2.3.5 development, test
duradura 7.0 8.0 = 7.0 development, test
zondrian 1.2 1.3 = 1.2 development, test
TABLE

expect(out).to end_with(expected_output)
end

it "puts together the gems from the same groups declared in a different order" do
install_gemfile <<-G
source "https://gem.repo2"

gem "terranova", '8'
group :test, :development do
gem 'activesupport', '2.3.5'
end
group :development, :test do
gem "duradura", '7.0'
end
G

update_repo2 do
build_gem "activesupport", "3.0"
build_gem "terranova", "9"
build_gem "duradura", "8.0"
end

bundle "outdated --groups", raise_on_error: false

expected_output = <<~TABLE.strip
Gem Current Latest Requested Groups Release Date
terranova 8 9 = 8 default
activesupport 2.3.5 3.0 = 2.3.5 development, test
duradura 7.0 8.0 = 7.0 development, test
TABLE

expect(out).to end_with(expected_output)
Expand Down