From 08b92b67ffdfbfaf53974457308b719f6e2d0d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 27 Aug 2024 23:35:43 +0200 Subject: [PATCH] [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 --- lib/bundler/source/git.rb | 4 ++-- spec/bundler/install/gemfile/git_spec.rb | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 9ce74adc2c..08a41a59ba 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -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 diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index d76a33f076..a544080fe6 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -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