[rubygems/rubygems] Don't blow up when explicit version is removed from some git sources

`version` is actually an attribute of the dependency, not of the git
source. Sometimes it's passed to the git source to be able to fake a
gemspec in case there's no gemspec in the source, but it should not be
used for source comparison.

https://github.com/rubygems/rubygems/commit/d936fbd78e
This commit is contained in:
David Rodríguez 2024-08-27 23:35:43 +02:00 committed by git
parent 63287fef9c
commit 08b92b67ff
2 changed files with 21 additions and 2 deletions

View File

@ -70,13 +70,13 @@ module Bundler
end
def hash
[self.class, uri, ref, branch, name, version, glob, submodules].hash
[self.class, uri, ref, branch, name, glob, submodules].hash
end
def eql?(other)
other.is_a?(Git) && uri == other.uri && ref == other.ref &&
branch == other.branch && name == other.name &&
version == other.version && glob == other.glob &&
glob == other.glob &&
submodules == other.submodules
end

View File

@ -1107,6 +1107,25 @@ RSpec.describe "bundle install with git sources" do
run "require 'new_file'"
expect(out).to eq("USING GIT")
end
it "doesn't explode when removing an explicit exact version from a git gem with dependencies" do
build_lib "activesupport", "7.1.4", path: lib_path("rails/activesupport")
build_git "rails", "7.1.4", path: lib_path("rails") do |s|
s.add_dependency "activesupport", "= 7.1.4"
end
install_gemfile <<-G
source "https://gem.repo1"
gem "rails", "7.1.4", :git => "#{lib_path("rails")}"
G
install_gemfile <<-G
source "https://gem.repo1"
gem "rails", :git => "#{lib_path("rails")}"
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