Skip to content

Commit

Permalink
Simplify checking Gemfile vs lockfile sources
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Jun 13, 2023
1 parent ad52f84 commit 251e80a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bundler/lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ def requested_dependencies
end

def current_dependencies
filter_relevant(dependencies)
end

def current_locked_dependencies
filter_relevant(locked_dependencies)
end

def filter_relevant(dependencies)
dependencies.select do |d|
d.should_include? && !d.gem_platforms([generic_local_platform]).empty?
end
Expand Down Expand Up @@ -382,13 +390,8 @@ def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?

both_sources = Hash.new {|h, k| h[k] = [] }
@dependencies.each {|d| both_sources[d.name][0] = d }

locked_dependencies.each do |d|
next if @locked_specs[d.name].empty?

both_sources[d.name][1] = d
end
current_dependencies.each {|d| both_sources[d.name][0] = d }
current_locked_dependencies.each {|d| both_sources[d.name][1] = d }

both_sources.each do |name, (dep, lock_dep)|
next if dep.nil? || lock_dep.nil?
Expand Down

0 comments on commit 251e80a

Please sign in to comment.