summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-01-17 14:10:46 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2020-02-27 21:21:35 +0100
commitb8da66bf6efde9f995999c2dce7e36603d9c2bb4 (patch)
treef9cc98205c13a0b3798d76558a814f839806fbb4
parent12181a40b1d069b8e862142cf7ee6a4da1b74e7c (diff)
downloadbundler-b8da66bf6efde9f995999c2dce7e36603d9c2bb4.tar.gz
Revert "Revert "Add all platforms to lockfile by default""
This reverts commit b5766564fb6ad9c74c3b87ad6b2965f3b9095d08.
-rw-r--r--lib/bundler/cli/outdated.rb6
-rw-r--r--lib/bundler/definition.rb8
-rw-r--r--spec/install/gemfile/platform_spec.rb26
-rw-r--r--spec/runtime/require_spec.rb2
4 files changed, 34 insertions, 8 deletions
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 3d4922f8b5..5f065654b1 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -76,6 +76,8 @@ module Bundler
next unless gems.empty? || gems.include?(current_spec.name)
active_spec = retrieve_active_spec(definition, current_spec)
+ next unless active_spec
+
next unless filter_options_patch.empty? || update_present_via_semver_portions(current_spec, active_spec, options)
gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
@@ -144,6 +146,8 @@ module Bundler
end
def retrieve_active_spec(definition, current_spec)
+ return unless current_spec.match_platform(Bundler.local_platform)
+
if strict
active_spec = definition.find_resolved_spec(current_spec)
else
@@ -231,8 +235,6 @@ module Bundler
end
def update_present_via_semver_portions(current_spec, active_spec, options)
- return false if active_spec.nil?
-
current_major = current_spec.version.segments.first
active_major = active_spec.version.segments.first
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index efd7618194..d723384189 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -117,7 +117,7 @@ module Bundler
end
@unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version)
- add_current_platform unless Bundler.frozen_bundle?
+ add_platforms unless Bundler.frozen_bundle?
converge_path_sources_to_gemspec_sources
@path_changes = converge_paths
@@ -548,6 +548,12 @@ module Bundler
private
+ def add_platforms
+ (@dependencies.flat_map(&:expanded_platforms) + current_platforms).uniq.each do |platform|
+ add_platform(platform)
+ end
+ end
+
def current_platforms
current_platform = Bundler.local_platform
[].tap do |platforms|
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb
index 52e1cf86fa..2bbda133c9 100644
--- a/spec/install/gemfile/platform_spec.rb
+++ b/spec/install/gemfile/platform_spec.rb
@@ -378,7 +378,7 @@ RSpec.describe "bundle install with platform conditionals" do
expect(out).not_to match(/Could not find gem 'some_gem/)
end
- it "prints a helpful warning when a dependency is unused on any platform" do
+ it "resolves all platforms by default and without warning messages" do
simulate_platform "ruby"
simulate_ruby_engine "ruby"
@@ -390,9 +390,27 @@ RSpec.describe "bundle install with platform conditionals" do
bundle! "install"
- expect(err).to include <<-O.strip
-The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
- O
+ expect(err).to be_empty
+
+ lockfile_should_be <<-L
+ GEM
+ remote: #{file_uri_for(gem_repo1)}/
+ specs:
+ rack (1.0.0)
+
+ PLATFORMS
+ java
+ ruby
+ x64-mingw32
+ x86-mingw32
+ x86-mswin32
+
+ DEPENDENCIES
+ rack
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
end
context "when disable_platform_warnings is true" do
diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb
index a2e6ba7244..3b9021b4fc 100644
--- a/spec/runtime/require_spec.rb
+++ b/spec/runtime/require_spec.rb
@@ -423,7 +423,7 @@ RSpec.describe "Bundler.require with platform specific dependencies" do
source "#{file_uri_for(gem_repo1)}"
platforms :#{not_local_tag} do
- gem "fail", :require => "omgomg"
+ gem "platform_specific", :require => "omgomg"
end
gem "rack", "1.0.0"