Skip to content

Commit

Permalink
Auto merge of rubygems#4465 - RochesterinNYC:only-show-potential-upda…
Browse files Browse the repository at this point in the history
…tes-on-same-platform, r=RochesterinNYC

Only show potential updates on same platform for `bundle outdated`

This fixes the following behavior:

Say you're using a gem `laduradura` on platform `java` with version `v1.0.1`. The latest `java` platform version of this gem is `v1.0.1` but the latest `ruby` platform version of this gem is `v1.0.2`. Running `bundle outdated` will currently tell you that you can update `laduradura` to `v1.0.2`.

This is a bad user experience as the user is given the suggestion to update `laduradura` to `v1.0.2`, despite this version being on a completely different platform than the one that the user is currently using `laduradura` on.

With this PR, `bundle outdated` will only report potential version updates to gems for the same platforms those gems are being used on.

- Fixes rubygems#4450
  • Loading branch information
homu committed May 9, 2016
2 parents cd21922 + cc35586 commit 10a2254
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/bundler/cli/outdated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def run
dependency = current_dependencies[current_spec.name]

if options["strict"]
active_spec = definition.specs.detect {|spec| spec.name == current_spec.name }
active_spec = definition.specs.detect {|spec| spec.name == current_spec.name && spec.platform == current_spec.platform }
else
active_spec = definition.index[current_spec.name].sort_by(&:version)
if !current_spec.version.prerelease? && !options[:pre] && active_spec.size > 1
active_spec = active_spec.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
active_specs = definition.index[current_spec.name].select {|spec| spec.platform == current_spec.platform }.sort_by(&:version)
if !current_spec.version.prerelease? && !options[:pre] && active_specs.size > 1
active_spec = active_specs.delete_if {|b| b.respond_to?(:version) && b.version.prerelease? }
end
active_spec = active_spec.last
active_spec = active_specs.last

if options[:major] || options[:minor] || options[:patch]
update_present = update_present_via_semver_portions(current_spec, active_spec, options)
Expand Down
14 changes: 14 additions & 0 deletions spec/commands/outdated_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@
end
end

context "update available for a gem on a different platform" do
before do
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "laduradura", '= 5.15.2'
G
end

it "reports that no updates are available" do
bundle "outdated"
expect(out).to include("Bundle up to date!")
end
end

shared_examples_for "version update is detected" do
it "reports that a gem has a newer version" do
subject
Expand Down
10 changes: 10 additions & 0 deletions spec/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ def build_repo1
s.add_dependency "weakling", ">= 0.0.3"
end

build_gem "laduradura", "5.15.2"
build_gem "laduradura", "5.15.2" do |s|
s.platform = "java"
s.write "lib/laduradura.rb", "LADURADURA = '5.15.2 JAVA'"
end
build_gem "laduradura", "5.15.3" do |s|
s.platform = "java"
s.write "lib/laduradura.rb", "LADURADURA = '5.15.2 JAVA'"
end

build_gem "weakling", "0.0.3"

build_gem "terranova", "8"
Expand Down

0 comments on commit 10a2254

Please sign in to comment.