Skip to content

Commit 5bff692

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Refactor replacing locked specification path sources
Instead of doing an explicit pass, let sources be replaced while checking if specifications are up to date. ruby/rubygems@676271e804
1 parent 28943c2 commit 5bff692

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

lib/bundler/definition.rb

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti
147147

148148
@current_platform_missing = add_current_platform unless Bundler.frozen_bundle?
149149

150-
converge_path_sources_to_gemspec_sources
151150
@path_changes = converge_paths
152151
@source_changes = converge_sources
153152

@@ -842,7 +841,7 @@ def dependencies_for_source_changed?(source, locked_source)
842841

843842
def specs_for_source_changed?(source)
844843
locked_index = Index.new
845-
locked_index.use(@locked_specs.select {|s| source.can_lock?(s) })
844+
locked_index.use(@locked_specs.select {|s| s.replace_source_with!(source) })
846845

847846
!locked_index.subset?(source.specs)
848847
rescue PathError, GitError => e
@@ -904,18 +903,6 @@ def converge_paths
904903
end
905904
end
906905

907-
def converge_path_source_to_gemspec_source(source)
908-
return source unless source.instance_of?(Source::Path)
909-
gemspec_source = sources.path_sources.find {|s| s == source }
910-
gemspec_source || source
911-
end
912-
913-
def converge_path_sources_to_gemspec_sources
914-
@locked_specs.each do |spec|
915-
spec.source &&= converge_path_source_to_gemspec_source(spec.source)
916-
end
917-
end
918-
919906
def converge_sources
920907
# Replace the sources from the Gemfile with the sources from the Gemfile.lock,
921908
# if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent

lib/bundler/lazy_specification.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ def force_ruby_platform!
175175
@force_ruby_platform = true
176176
end
177177

178+
def replace_source_with!(gemfile_source)
179+
return unless gemfile_source.can_lock?(self)
180+
181+
@source = gemfile_source
182+
183+
true
184+
end
185+
178186
private
179187

180188
def use_exact_resolved_specifications?

0 commit comments

Comments
 (0)