Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -974,10 +974,10 @@ def compute_requires

def additional_base_requirements_for_resolve
return [] unless @locked_gems && Bundler.feature_flag.only_update_to_newer_versions?
dependencies_by_name = dependencies.group_by(&:name)
dependencies_by_name = dependencies.inject({}) {|memo, dep| memo.update(dep.name => dep) }
@locked_gems.specs.reduce({}) do |requirements, locked_spec|
name = locked_spec.name
next requirements if @locked_deps[name] != dependencies_by_name[name]
next requirements if @locked_gems.dependencies[name] != dependencies_by_name[name]
dep = Gem::Dependency.new(name, ">= #{locked_spec.version}")
requirements[name] = DepProxy.new(dep, locked_spec.platform)
requirements
Expand Down
56 changes: 45 additions & 11 deletions spec/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,33 +134,67 @@
before do
bundle! "config only_update_to_newer_versions true"
end

it "does not go to an older version" do
build_repo4 do
build_gem "a" do |s|
s.add_dependency "b"
s.add_dependency "c"
build_gem "tilt", "2.0.8"
build_gem "slim", "3.0.9" do |s|
s.add_dependency "tilt", [">= 1.3.3", "< 2.1"]
end
build_gem "slim_lint", "0.16.1" do |s|
s.add_dependency "slim", [">= 3.0", "< 5.0"]
end
build_gem "slim-rails", "0.2.1" do |s|
s.add_dependency "slim", ">= 0.9.2"
end
build_gem "slim-rails", "3.1.3" do |s|
s.add_dependency "slim", "~> 3.0"
end
build_gem "b"
build_gem "c"
build_gem "c", "2.0"
end

install_gemfile! <<-G
source "file:#{gem_repo4}"
gem "a"
gem "slim-rails"
gem "slim_lint"
G

expect(the_bundle).to include_gems("a 1.0", "b 1.0", "c 2.0")
expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1")

update_repo4 do
build_gem "b", "2.0" do |s|
s.add_dependency "c", "< 2"
build_gem "slim", "4.0.0" do |s|
s.add_dependency "tilt", [">= 2.0.6", "< 2.1"]
end
end

bundle! "update", :all => bundle_update_requires_all?

expect(the_bundle).to include_gems("a 1.0", "b 1.0", "c 2.0")
expect(the_bundle).to include_gems("slim 3.0.9", "slim-rails 3.1.3", "slim_lint 0.16.1")
end

it "should still downgrade if forced by the Gemfile" do
build_repo4 do
build_gem "a"
build_gem "b", "1.0"
build_gem "b", "2.0"
end

install_gemfile! <<-G
source "file:#{gem_repo4}"
gem "a"
gem "b"
G

expect(the_bundle).to include_gems("a 1.0", "b 2.0")

gemfile <<-G
source "file://#{gem_repo4}"
gem "a"
gem "b", "1.0"
G

bundle! "update b"

expect(the_bundle).to include_gems("a 1.0", "b 1.0")
end
end
end
Expand Down