Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit 3e5d59a

Browse files
committed
Auto merge of #5343 - bundler:seg-converge-sources-first, r=indirect
[Definition] Converge sources before anything else Fixes #5340 Improves handling of gemspec sources by ensuring they're converged before anything else, and also converging the locked dependency sources so that `dependencies_for_source_changed?` doesn't get tripped up - [x] test coverage
2 parents c79e1b2 + 2e9846e commit 3e5d59a

File tree

4 files changed

+34
-11
lines changed

4 files changed

+34
-11
lines changed

lib/bundler/definition.rb

+10-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
104104

105105
add_current_platform unless Bundler.settings[:frozen]
106106

107+
converge_gemspec_sources
107108
@path_changes = converge_paths
109+
@source_changes = converge_sources
108110

109111
unless @unlock[:lock_shared_dependencies]
110112
eager_unlock = expand_dependencies(@unlock[:gems])
@@ -113,7 +115,6 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
113115

114116
@gem_version_promoter = create_gem_version_promoter
115117

116-
@source_changes = converge_sources
117118
@dependency_changes = converge_dependencies
118119
@local_changes = converge_locals
119120

@@ -627,15 +628,20 @@ def converge_path_source_to_gemspec_source(source)
627628
gemspec_source || source
628629
end
629630

630-
def converge_sources
631-
changes = false
632-
631+
def converge_gemspec_sources
633632
@locked_sources.map! do |source|
634633
converge_path_source_to_gemspec_source(source)
635634
end
636635
@locked_specs.each do |spec|
637636
spec.source &&= converge_path_source_to_gemspec_source(spec.source)
638637
end
638+
@locked_deps.each do |dep|
639+
dep.source &&= converge_path_source_to_gemspec_source(dep.source)
640+
end
641+
end
642+
643+
def converge_sources
644+
changes = false
639645

640646
# Get the Rubygems sources from the Gemfile.lock
641647
locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }

lib/bundler/installer/parallel_installer.rb

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def missing_lockfile_dependencies(all_spec_names)
6767
def all_dependencies
6868
@spec.dependencies
6969
end
70+
71+
def to_s
72+
"#<#{self.class} #{@spec.full_name} (#{state})>"
73+
end
7074
end
7175

7276
def self.call(*args)

spec/install/deploy_spec.rb

+6-7
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,21 @@
267267
context "with path in Gemfile and packed" do
268268
it "works fine after bundle package and bundle install --local" do
269269
build_lib "foo", :path => lib_path("foo")
270-
install_gemfile <<-G
271-
gem "foo", :path => "#{lib_path("foo")}"
270+
install_gemfile! <<-G
271+
gem "foo", :path => "#{lib_path("foo")}"
272272
G
273273

274-
bundle :install
274+
bundle! :install
275275
expect(the_bundle).to include_gems "foo 1.0"
276-
bundle "package --all"
276+
bundle! "package --all"
277277
expect(bundled_app("vendor/cache/foo")).to be_directory
278278

279-
bundle "install --local"
279+
bundle! "install --local"
280280
expect(out).to include("Using foo 1.0 from source at")
281281
expect(out).to include("vendor/cache/foo")
282-
expect(exitstatus).to eq(0) if exitstatus
283282

284283
simulate_new_machine
285-
bundle "install --deployment"
284+
bundle! "install --deployment --verbose"
286285
expect(out).not_to include("You are trying to install in deployment mode after changing your Gemfile")
287286
expect(out).not_to include("You have added to the Gemfile")
288287
expect(out).not_to include("You have deleted from the Gemfile")

spec/install/gemfile/gemspec_spec.rb

+14
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@
131131
end
132132
end
133133

134+
it "should match a lockfile without needing to re-resolve" do
135+
build_lib("foo", :path => tmp.join("foo")) do |s|
136+
s.add_dependency "rack"
137+
end
138+
139+
install_gemfile! <<-G
140+
source "file://#{gem_repo1}"
141+
gemspec :path => '#{tmp.join("foo")}'
142+
G
143+
144+
bundle! "install", :verbose => true
145+
expect(out).to include("Found no changes, using resolution from the lockfile")
146+
end
147+
134148
it "should evaluate the gemspec in its directory" do
135149
build_lib("foo", :path => tmp.join("foo"))
136150
File.open(tmp.join("foo/foo.gemspec"), "w") do |s|

0 commit comments

Comments
 (0)