From ed5f8eaf490fee0b186496b82519c5be29ec7e8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 26 Oct 2021 13:35:51 +0200 Subject: [rubygems/rubygems] Don't warn when a lockfile is locked to a dev version Even if it's newer than the running versions. Dev versions are not released to rubygems.org, so the warning message suggests a command that doesn't work. And dev versions are currently non deterministic (2.3.0.dev can be many different versions), so the warning doesn't really make sense at the moment. https://github.com/rubygems/rubygems/commit/6f31af27ef --- lib/bundler/lockfile_parser.rb | 1 + spec/bundler/lock/lockfile_spec.rb | 108 ++++++++++++++++++++++++++++++++++--- 2 files changed, 103 insertions(+), 6 deletions(-) diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 8d0e44d0ae..6ff4910a36 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -86,6 +86,7 @@ module Bundler def warn_for_outdated_bundler_version return unless bundler_version + return if bundler_version.segments.last == "dev" prerelease_text = bundler_version.prerelease? ? " --pre" : "" current_version = Gem::Version.create(Bundler::VERSION) return unless current_version < bundler_version diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 4e9e0f5fc3..9170efeedd 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -166,9 +166,10 @@ RSpec.describe "the lockfile format" do G end - it "warns if the current is older than lockfile's bundler version" do - current_version = Bundler::VERSION - newer_minor = bump_minor(current_version) + it "warns if the current version is older than lockfile's bundler version, and locked version is a final release" do + current_version = "999.998.999" + system_gems "bundler-#{current_version}" + newer_minor = "999.999.0" lockfile <<-L GEM @@ -186,17 +187,66 @@ RSpec.describe "the lockfile format" do #{newer_minor} L - install_gemfile <<-G + install_gemfile <<-G, :env => { "BUNDLER_VERSION" => current_version } + source "#{file_uri_for(gem_repo2)}" + + gem "rack" + G + + warning_message = "the running version of Bundler (#{current_version}) is older " \ + "than the version that created the lockfile (#{newer_minor}). " \ + "We suggest you to upgrade to the version that created the " \ + "lockfile by running `gem install bundler:#{newer_minor}`." + expect(err).to include warning_message + + lockfile_should_be <<-G + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: + rack (1.0.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + #{newer_minor} + G + end + + it "warns if the current version is older than lockfile's bundler version, and locked version is a prerelease" do + current_version = "999.998.999" + system_gems "bundler-#{current_version}" + newer_minor = "999.999.0.pre1" + + lockfile <<-L + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: + rack (1.0.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + #{newer_minor} + L + + install_gemfile <<-G, :env => { "BUNDLER_VERSION" => current_version } source "#{file_uri_for(gem_repo2)}" gem "rack" G - pre_flag = prerelease?(newer_minor) ? " --pre" : "" warning_message = "the running version of Bundler (#{current_version}) is older " \ "than the version that created the lockfile (#{newer_minor}). " \ "We suggest you to upgrade to the version that created the " \ - "lockfile by running `gem install bundler:#{newer_minor}#{pre_flag}`." + "lockfile by running `gem install bundler:#{newer_minor} --pre`." expect(err).to include warning_message lockfile_should_be <<-G @@ -216,6 +266,52 @@ RSpec.describe "the lockfile format" do G end + it "doesn't warn if the current version is older than lockfile's bundler version, and locked version is a dev version" do + current_version = "999.998.999" + system_gems "bundler-#{current_version}" + newer_minor = "999.999.0.dev" + + lockfile <<-L + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: + rack (1.0.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + #{newer_minor} + L + + install_gemfile <<-G, :env => { "BUNDLER_VERSION" => current_version } + source "#{file_uri_for(gem_repo2)}" + + gem "rack" + G + + expect(err).to be_empty + + lockfile_should_be <<-G + GEM + remote: #{file_uri_for(gem_repo2)}/ + specs: + rack (1.0.0) + + PLATFORMS + #{lockfile_platforms} + + DEPENDENCIES + rack + + BUNDLED WITH + #{newer_minor} + G + end + it "warns when updating bundler major version" do current_version = Bundler::VERSION older_major = previous_major(current_version) -- cgit v1.2.1