[rubygems/rubygems] Fix `bundle remove` by invalidating cached `Bundle.defintion`.

Prior to this commit, `bundle add GEM_NAME` updated the lockfile,
but `bundle remove GEM_NAME` left GEM_NAME in the lockfile.

By invalidating the cached `Bundle.definition`, the existing code
handles that without a problem.

https://github.com/rubygems/rubygems/commit/aa0794d6a9
This commit is contained in:
Ellen Marie Dash 2022-03-31 23:44:31 +00:00 коммит произвёл git
Родитель 0a6b9924bd
Коммит 1177665e62
2 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -72,6 +72,10 @@ module Bundler
deps.each {|dep| Bundler.ui.confirm "#{SharedHelpers.pretty_dependency(dep, false)} was removed." } deps.each {|dep| Bundler.ui.confirm "#{SharedHelpers.pretty_dependency(dep, false)} was removed." }
end end
# Invalidate the cached Bundler.definition.
# This prevents e.g. `bundle remove ...` from using outdated information.
Bundler.reset_paths!
end end
private private

Просмотреть файл

@ -13,6 +13,36 @@ RSpec.describe "bundle remove" do
end end
end end
context "after 'bundle install' is run" do
describe "running 'bundle remove GEM_NAME'" do
it "removes it from the lockfile" do
rack_dep = <<~L
DEPENDENCIES
rack
L
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
G
bundle "install"
expect(lockfile).to include(rack_dep)
bundle "remove rack"
expect(gemfile).to eq <<~G
source "#{file_uri_for(gem_repo1)}"
G
expect(lockfile).to_not include(rack_dep)
end
end
end
context "when --install flag is specified", :bundler => "< 3" do context "when --install flag is specified", :bundler => "< 3" do
it "removes gems from .bundle" do it "removes gems from .bundle" do
gemfile <<-G gemfile <<-G