This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature-flag the postit trampoline, disabled by default
Set ENV["BUNDLE_ENABLE_TRAMPOLINE"] to enable it
- Loading branch information
Showing
2 changed files
with
51 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,65 @@ | ||
# frozen_string_literal: true | ||
if ENV["BUNDLE_ENABLE_TRAMPOLINE"] | ||
|
||
module BundlerVendoredPostIt; end | ||
require "bundler/vendor/postit/lib/postit" | ||
require "rubygems" | ||
module BundlerVendoredPostIt; end | ||
require "bundler/vendor/postit/lib/postit" | ||
require "rubygems" | ||
|
||
environment = BundlerVendoredPostIt::PostIt::Environment.new([]) | ||
version = Gem::Requirement.new(environment.bundler_version) | ||
environment = BundlerVendoredPostIt::PostIt::Environment.new([]) | ||
version = Gem::Requirement.new(environment.bundler_version) | ||
|
||
installed_version = | ||
if defined?(Bundler::VERSION) | ||
Bundler::VERSION | ||
else | ||
File.read(File.expand_path("../version.rb", __FILE__)) =~ /VERSION = "(.+)"/ | ||
$1 | ||
end | ||
installed_version &&= Gem::Version.new(installed_version) | ||
|
||
if !version.satisfied_by?(installed_version) | ||
begin | ||
installer = BundlerVendoredPostIt::PostIt::Installer.new(version) | ||
installer.install! | ||
rescue => e | ||
abort <<-EOS.strip | ||
installed_version = | ||
if defined?(Bundler::VERSION) | ||
Bundler::VERSION | ||
else | ||
File.read(File.expand_path("../version.rb", __FILE__)) =~ /VERSION = "(.+)"/ | ||
$1 | ||
end | ||
installed_version &&= Gem::Version.new(installed_version) | ||
|
||
if !version.satisfied_by?(installed_version) | ||
begin | ||
installer = BundlerVendoredPostIt::PostIt::Installer.new(version) | ||
installer.install! | ||
rescue => e | ||
abort <<-EOS.strip | ||
Installing the inferred bundler version (#{version}) failed. | ||
If you'd like to update to the current bundler version (#{installed_version}) in this project, run `bundle update --bundler`. | ||
The error was: #{e} | ||
EOS | ||
end | ||
end | ||
|
||
if deleted_spec = Gem.loaded_specs.delete("bundler") | ||
deleted_spec.full_require_paths.each {|path| $:.delete(path) } | ||
if deleted_spec = Gem.loaded_specs.delete("bundler") | ||
deleted_spec.full_require_paths.each {|path| $:.delete(path) } | ||
else | ||
$:.delete(File.expand_path("../..", __FILE__)) | ||
end | ||
gem "bundler", version | ||
else | ||
$:.delete(File.expand_path("../..", __FILE__)) | ||
begin | ||
gem "bundler", version | ||
rescue LoadError | ||
$:.unshift(File.expand_path("../..", __FILE__)) | ||
end | ||
end | ||
gem "bundler", version | ||
else | ||
begin | ||
gem "bundler", version | ||
rescue LoadError | ||
$:.unshift(File.expand_path("../..", __FILE__)) | ||
|
||
running_version = begin | ||
require "bundler/version" | ||
Bundler::VERSION | ||
rescue LoadError, NameError | ||
nil | ||
end | ||
end | ||
|
||
running_version = begin | ||
require "bundler/version" | ||
Bundler::VERSION | ||
rescue LoadError, NameError | ||
nil | ||
end | ||
|
||
if Gem::Requirement.new(">= 1.13.pre".dup).satisfied_by?(Gem::Version.new(running_version)) | ||
ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"] = installed_version.to_s | ||
elsif ARGV.empty? || ARGV.any? {|a| %w(install i).include? a } | ||
puts <<-WARN.strip | ||
|
||
if Gem::Requirement.new(">= 1.13.pre".dup).satisfied_by?(Gem::Version.new(running_version)) | ||
ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"] = installed_version.to_s | ||
elsif ARGV.empty? || ARGV.any? {|a| %w(install i).include? a } | ||
puts <<-WARN.strip | ||
You're running Bundler #{installed_version} but this project uses #{running_version}. To update, run `bundle update --bundler`. | ||
WARN | ||
end | ||
end | ||
|
||
if !Gem::Version.correct?(running_version.to_s) || !version.satisfied_by?(Gem::Version.create(running_version)) | ||
abort "The running bundler (#{running_version}) does not match the required `#{version}`" | ||
end | ||
|
||
if !Gem::Version.correct?(running_version.to_s) || !version.satisfied_by?(Gem::Version.create(running_version)) | ||
abort "The running bundler (#{running_version}) does not match the required `#{version}`" | ||
end | ||
end # unless ENV["BUNDLE_ENABLE_TRAMPOLINE"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters