summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/definition.rb12
-rw-r--r--spec/bundler/lock/lockfile_spec.rb68
2 files changed, 77 insertions, 3 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 49627cc562..cc2394fda6 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -282,12 +282,17 @@ module Bundler
end
def filter_relevant(dependencies)
- platforms_array = [Bundler.generic_local_platform].freeze
dependencies.select do |d|
- d.should_include? && !d.gem_platforms(platforms_array).empty?
+ relevant_deps?(d)
end
end
+ def relevant_deps?(dep)
+ platforms_array = [Bundler.generic_local_platform].freeze
+
+ dep.should_include? && !dep.gem_platforms(platforms_array).empty?
+ end
+
def locked_dependencies
@locked_deps.values
end
@@ -973,10 +978,11 @@ module Bundler
@missing_lockfile_dep = nil
@changed_dependencies = []
- current_dependencies.each do |dep|
+ @dependencies.each do |dep|
if dep.source
dep.source = sources.get(dep.source)
end
+ next unless relevant_deps?(dep)
name = dep.name
diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb
index 4b767c7415..02e53454d8 100644
--- a/spec/bundler/lock/lockfile_spec.rb
+++ b/spec/bundler/lock/lockfile_spec.rb
@@ -2111,6 +2111,74 @@ RSpec.describe "the lockfile format" do
L
end
+ it "successfully updates the lockfile when a new gem is added in the Gemfile includes a gem that shouldn't be included" do
+ build_repo4 do
+ build_gem "logger", "1.7.0"
+ build_gem "rack", "3.2.0"
+ build_gem "net-smtp", "0.5.0"
+ end
+
+ gemfile <<~G
+ source "#{file_uri_for(gem_repo4)}"
+ gem "logger"
+ gem "net-smtp"
+
+ install_if -> { false } do
+ gem 'rack', github: 'rack/rack'
+ end
+ G
+
+ lockfile <<~L
+ GIT
+ remote: https://github.com/rack/rack.git
+ revision: 2fface9ac09fc582a81386becd939c987ad33f99
+ specs:
+ rack (3.2.0)
+
+ GEM
+ remote: #{file_uri_for(gem_repo4)}/
+ specs:
+ logger (1.7.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ logger
+ rack!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+
+ bundle "install"
+
+ expect(lockfile).to eq <<~L
+ GIT
+ remote: https://github.com/rack/rack.git
+ revision: 2fface9ac09fc582a81386becd939c987ad33f99
+ specs:
+ rack (3.2.0)
+
+ GEM
+ remote: #{file_uri_for(gem_repo4)}/
+ specs:
+ logger (1.7.0)
+ net-smtp (0.5.0)
+
+ PLATFORMS
+ #{lockfile_platforms}
+
+ DEPENDENCIES
+ logger
+ net-smtp
+ rack!
+
+ BUNDLED WITH
+ #{Bundler::VERSION}
+ L
+ end
+
shared_examples_for "a lockfile missing dependent specs" do
it "auto-heals" do
build_repo4 do