aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler
diff options
context:
space:
mode:
authorAndré Arko <mail@arko.net>2015-05-04 19:15:26 -0700
committerAndré Arko <mail@arko.net>2015-05-04 19:15:26 -0700
commit8050cd6a41d94851a6a6fad2fdb29b9b534bc74c (patch)
tree320ebf442e293dea71aa073add93f092045c6b78 /lib/bundler
parentd8df35c18db3c300e8191d53eb06c6437876d948 (diff)
parent91b0e741c385ba1189521cb1d982588e834986de (diff)
downloadbundler-8050cd6a41d94851a6a6fad2fdb29b9b534bc74c.tar.gz
Merge pull request #3612 from bundler/seg-major-version-erros
Warn when upgrading lockfile major version & error when major version is...
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/definition.rb10
-rw-r--r--lib/bundler/lockfile_parser.rb16
2 files changed, 21 insertions, 5 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index d8aab4fb..eb97b81a 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -249,6 +249,16 @@ module Bundler
return
end
+ if @locked_bundler_version
+ locked_major = @locked_bundler_version.segments.first
+ current_major = Gem::Version.create(Bundler::VERSION).segments.first
+
+ if locked_major < current_major
+ Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{Bundler::VERSION.split('.').first}, " \
+ "after which you will be unable to return to Bundler #{@locked_bundler_version.segments.first}."
+ end
+ end
+
File.open(file, 'wb'){|f| f.puts(contents) }
rescue Errno::EACCES
raise Bundler::InstallError,
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index dcd966b9..21367fe7 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -60,11 +60,17 @@ module Bundler
def warn_for_outdated_bundler_version
return unless bundler_version
prerelease_text = bundler_version.prerelease? ? " --pre" : ""
- if Gem::Version.new(Bundler::VERSION) < Gem::Version.new(bundler_version)
- Bundler.ui.warn "Warning: the running version of Bundler is older " \
- "than the version that created the lockfile. We suggest you " \
- "upgrade to the latest version of Bundler by running `gem " \
- "install bundler#{prerelease_text}`.\n"
+ current_version = Gem::Version.create(Bundler::VERSION)
+ case current_version.segments.first <=> bundler_version.segments.first
+ when -1
+ raise LockfileError, "You must use Bundler #{bundler_version.segments.first} or greater with this lockfile."
+ when 0
+ if current_version < bundler_version
+ Bundler.ui.warn "Warning: the running version of Bundler is older " \
+ "than the version that created the lockfile. We suggest you " \
+ "upgrade to the latest version of Bundler by running `gem " \
+ "install bundler#{prerelease_text}`.\n"
+ end
end
end