[rubygems/rubygems] Fix git source unlocking for multi-gem repositories like Rails
If you have ``` gem "rails", git: "https://github.com/rails/rails" ``` and then explicitly pin to an older ref, like ``` gem "rails", git: "https://github.com/rails/rails", ref: "https://github.com/rubygems/rubygems/commit/99bacb5aa8e5" ``` Then `bundle install` fails, because locked sources fail to be updated to use the new source. This commit fixes the problem by making sure get their source properly replaced. https://github.com/rubygems/rubygems/commit/5de8c2e0cf
This commit is contained in:
parent
e4933e1d93
commit
970eac1530
@ -1045,7 +1045,7 @@ module Bundler
|
||||
s.source = gemfile_source
|
||||
else
|
||||
# Replace the locked dependency's source with the default source, if the locked source is no longer in the Gemfile
|
||||
s.source = default_source unless sources.get(lockfile_source)
|
||||
s.source = sources.get(lockfile_source) || default_source
|
||||
end
|
||||
|
||||
source = s.source
|
||||
|
@ -103,7 +103,7 @@ module Bundler
|
||||
end
|
||||
|
||||
def get(source)
|
||||
source_list_for(source).find {|s| equivalent_source?(source, s) }
|
||||
source_list_for(source).find {|s| s.include?(source) }
|
||||
end
|
||||
|
||||
def lock_sources
|
||||
@ -265,9 +265,5 @@ module Bundler
|
||||
def equivalent_sources?(lock_sources, replacement_sources)
|
||||
lock_sources.sort_by(&:identifier) == replacement_sources.sort_by(&:identifier)
|
||||
end
|
||||
|
||||
def equivalent_source?(source, other_source)
|
||||
source == other_source
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1151,6 +1151,30 @@ RSpec.describe "bundle install with git sources" do
|
||||
|
||||
expect(the_bundle).to include_gem "rails 7.1.4", "activesupport 7.1.4"
|
||||
end
|
||||
|
||||
it "doesn't explode when adding an explicit ref to a git gem with dependencies" do
|
||||
lib_root = lib_path("rails")
|
||||
|
||||
build_lib "activesupport", "7.1.4", path: lib_root.join("activesupport")
|
||||
build_git "rails", "7.1.4", path: lib_root do |s|
|
||||
s.add_dependency "activesupport", "= 7.1.4"
|
||||
end
|
||||
|
||||
old_revision = revision_for(lib_root)
|
||||
update_git "rails", "7.1.4", path: lib_root
|
||||
|
||||
install_gemfile <<-G
|
||||
source "https://gem.repo1"
|
||||
gem "rails", "7.1.4", :git => "#{lib_root}"
|
||||
G
|
||||
|
||||
install_gemfile <<-G
|
||||
source "https://gem.repo1"
|
||||
gem "rails", :git => "#{lib_root}", :ref => "#{old_revision}"
|
||||
G
|
||||
|
||||
expect(the_bundle).to include_gem "rails 7.1.4", "activesupport 7.1.4"
|
||||
end
|
||||
end
|
||||
|
||||
describe "bundle install after the remote has been updated" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user