Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Remove the lockfile warnings
Browse files Browse the repository at this point in the history
Let's rely on the BundlerVersionFinder to shortcircuit this.
  • Loading branch information
deivid-rodriguez committed Apr 24, 2019
1 parent 535c4fe commit aba7f18
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 163 deletions.
17 changes: 0 additions & 17 deletions lib/bundler/lockfile_parser.rb
Expand Up @@ -90,29 +90,12 @@ def initialize(lockfile)
end
@sources << @rubygems_aggregate unless Bundler.feature_flag.disable_multisource?
@specs = @specs.values.sort_by(&:identifier)
warn_for_outdated_bundler_version
rescue ArgumentError => e
Bundler.ui.debug(e)
raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
"and then `bundle install` to generate a new lockfile."
end

def warn_for_outdated_bundler_version
return unless bundler_version
prerelease_text = bundler_version.prerelease? ? " --pre" : ""
current_version = Gem::Version.create(Bundler::VERSION)
current_major_version = current_version.segments.first
current_locked_version = bundler_version.segments.first
if current_major_version < current_locked_version && current_major_version > 2
raise LockfileError, "You must use Bundler #{current_locked_version} or greater with this lockfile."
end
return unless current_version < bundler_version
Bundler.ui.warn "Warning: the running version of Bundler (#{current_version}) is older " \
"than the version that created the lockfile (#{bundler_version}). We suggest you to " \
"upgrade to the version that created the lockfile by running `gem install " \
"bundler:#{bundler_version}#{prerelease_text}`.\n"
end

private

TYPES = {
Expand Down
146 changes: 0 additions & 146 deletions spec/lock/lockfile_spec.rb
Expand Up @@ -154,136 +154,6 @@
G
end

it "warns if the lockfile's major version matches, but has a higher patch or minor version" do
current_version = Bundler::VERSION
newer_minor = bump_minor(current_version)

lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
#{newer_minor}
L

install_gemfile <<-G
source "file://localhost#{gem_repo1}"
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}`."
expect(err).to include warning_message

lockfile_should_be <<-G
GEM
remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
#{newer_minor}
G
end

it "warns if the current major version is older than lockfile's major version", :bundler => "< 3" do
current_version = Bundler::VERSION
newer_major = bump_major(current_version)

lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
#{newer_major}
L

install_gemfile <<-G
source "file://localhost#{gem_repo1}"
gem "rack"
G

pre_flag = prerelease?(newer_major) ? " --pre" : ""
warning_message = "the running version of Bundler (#{current_version}) is older " \
"than the version that created the lockfile (#{newer_major}). " \
"We suggest you to upgrade to the version that created the " \
"lockfile by running `gem install bundler:#{newer_major}#{pre_flag}`."
expect(last_command.stderr).to include warning_message

lockfile_should_be <<-G
GEM
remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
#{newer_major}
G
end

it "errors if the current major version is older than lockfile's bundler version", :bundler => "3" do
current_version = Bundler::VERSION
newer_major = bump_major(current_version)

lockfile <<-L
GEM
remote: file://localhost#{gem_repo1}/
specs:
rack (1.0.0)
PLATFORMS
#{lockfile_platforms}
DEPENDENCIES
rack
BUNDLED WITH
#{newer_major}
L

install_gemfile <<-G
source "file://localhost#{gem_repo1}/"
gem "rack"
G

expect(last_command).to be_failure
expect(err).to include("You must use Bundler #{newer_major.split(".").first} or greater with this lockfile.")
end

it "warns when updating bundler major version" do
current_version = Bundler::VERSION
older_major = previous_major(current_version)
Expand Down Expand Up @@ -1554,23 +1424,7 @@ def set_lockfile_mtime_to_known_value

private

def prerelease?(version)
Gem::Version.new(version).prerelease?
end

def previous_major(version)
version.split(".").map.with_index {|v, i| i == 0 ? v.to_i - 1 : v }.join(".")
end

def bump_major(version)
bump(version, 0)
end

def bump_minor(version)
bump(version, 1)
end

def bump(version, segment)
version.split(".").map.with_index {|v, i| i == segment ? v.to_i + 1 : v }.join(".")
end
end

0 comments on commit aba7f18

Please sign in to comment.