Skip to content

Commit

Permalink
Automatically unlock dependants released in lockstep
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed May 12, 2022
1 parent c923d48 commit 2e32e86
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bundler/lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,14 @@ def converge_specs(specs)
end
end

extra_unlocks = specs.select do |s|
s.dependencies.any? do |dep|
@unlock[:gems].include?(dep.name) && dep.requirement.as_list == ["= #{s.version}"]
end
end.map(&:name)

@unlock[:gems] |= extra_unlocks

SpecSet.new(filter_specs(converged, deps).reject{|s| @unlock[:gems].include?(s.name) })
end

Expand Down
62 changes: 62 additions & 0 deletions bundler/spec/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,68 @@
end
end

describe "with a transitive dependency released in lockstep with its dependants" do
before do
build_repo4 do
build_gem "rails", "7.0.2.3" do |s|
s.add_dependency "actionview", "7.0.2.3"
end
build_gem "actionview", "7.0.2.3"

build_gem "rails", "7.0.2.4" do |s|
s.add_dependency "actionview", "7.0.2.4"
end
build_gem "actionview", "7.0.2.4"
end

gemfile <<~G
source "#{file_uri_for(gem_repo4)}"
gem "rails"
G

lockfile <<~L
GEM
remote: #{file_uri_for(gem_repo4)}/
specs:
actionview (7.0.2.3)
rails (7.0.2.3)
actionview (= 7.0.2.3)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rails
BUNDLED WITH
#{Bundler::VERSION}
L
end

it "works" do
bundle "update actionview"

expect(lockfile).to eq <<~L
GEM
remote: #{file_uri_for(gem_repo4)}/
specs:
actionview (7.0.2.4)
rails (7.0.2.4)
actionview (= 7.0.2.4)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rails
BUNDLED WITH
#{Bundler::VERSION}
L
end
end

describe "with an unknown dependency" do
before do
build_repo2
Expand Down

0 comments on commit 2e32e86

Please sign in to comment.