Skip to content

Commit

Permalink
filtered outdated msg shouldn't say 'up to date'
Browse files Browse the repository at this point in the history
Fixes rubygems#5076. When a filter option is in use and it filters out
everything in the requested categories, it's safer to say there were no
%{level} updates to display rather than "Bundle up to date!"

Tracking an additional local variable with the exact info to know that
even when filtered there was nothing to update anyway I didn't feel was
worth it with the current design.
  • Loading branch information
chrismo committed Oct 19, 2016
1 parent b8c23f3 commit 9c1c3a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 13 additions & 1 deletion lib/bundler/cli/outdated.rb
Expand Up @@ -94,7 +94,7 @@ def run
end

if outdated_gems_list.empty?
Bundler.ui.info "Bundle up to date!\n" unless options[:parseable]
display_nothing_outdated_message
else
unless options[:parseable]
if options[:pre]
Expand Down Expand Up @@ -141,6 +141,18 @@ def run

private

def display_nothing_outdated_message
unless options[:parseable]
filter_options = options.keys & %w(filter-major filter-minor filter-patch)
if filter_options.any?
display = filter_options.map {|o| o.sub("filter-", "") }.join(" or ")
Bundler.ui.info "No #{display} updates to display.\n"
else
Bundler.ui.info "Bundle up to date!\n"
end
end
end

def print_gem(current_spec, active_spec, dependency, groups, options_include_groups)
spec_version = "#{active_spec.version}#{active_spec.git_version}"
current_version = "#{current_spec.version}#{current_spec.git_version}"
Expand Down
10 changes: 5 additions & 5 deletions spec/commands/outdated_spec.rb
Expand Up @@ -326,7 +326,7 @@ def test_group_option(group = nil, gems_list_size = 1)
bundle "outdated --strict --filter-patch"

expect(out).to_not include("activesupport (newest")
expect(out).to include("(newest 0.0.5, installed 0.0.3)")
expect(out).to include("(newest 0.0.5, installed 0.0.3")
end

it "only reports gems that match requirement and minor filter level" do
Expand All @@ -344,7 +344,7 @@ def test_group_option(group = nil, gems_list_size = 1)
bundle "outdated --strict --filter-minor"

expect(out).to_not include("activesupport (newest")
expect(out).to include("(newest 0.1.5, installed 0.0.3)")
expect(out).to include("(newest 0.1.5, installed 0.0.3")
end

it "only reports gems that match requirement and major filter level" do
Expand All @@ -362,7 +362,7 @@ def test_group_option(group = nil, gems_list_size = 1)
bundle "outdated --strict --filter-major"

expect(out).to_not include("activesupport (newest")
expect(out).to include("(newest 1.1.5, installed 0.0.3)")
expect(out).to include("(newest 1.1.5, installed 0.0.3")
end
end
end
Expand Down Expand Up @@ -472,7 +472,7 @@ def test_group_option(group = nil, gems_list_size = 1)
shared_examples_for "no version updates are detected" do
it "does not detect any version updates" do
subject
expect(out).to include("Bundle up to date!")
expect(out).to include("updates to display.")
expect(out).to_not include("ERROR REPORT TEMPLATE")
expect(out).to_not include("activesupport (newest")
expect(out).to_not include("weakling (newest")
Expand Down Expand Up @@ -598,7 +598,7 @@ def test_group_option(group = nil, gems_list_size = 1)
it "shows nothing when patching and filtering to minor" do
bundle "outdated --patch --filter-minor"

expect(out).to include("Bundle up to date!") # it shouldn't say this, but will get back to this with: #5076
expect(out).to include("No minor updates to display.")
expect(out).not_to include("patch (newest")
expect(out).not_to include("minor (newest")
expect(out).not_to include("major (newest")
Expand Down

0 comments on commit 9c1c3a0

Please sign in to comment.