1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Merge Bundler-2.0.0.pre1 from upstream.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2018-11-12 00:53:15 +00:00
parent ab5a3db48e
commit 8f4aa4fd2a
36 changed files with 90 additions and 95 deletions

View file

@ -3,7 +3,7 @@
require "bundler/shared_helpers" require "bundler/shared_helpers"
Bundler::SharedHelpers.major_deprecation(2, "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`") Bundler::SharedHelpers.major_deprecation(3, "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`")
Signal.trap("INT") { exit 1 } Signal.trap("INT") { exit 1 }

View file

@ -119,7 +119,7 @@ module Bundler
end end
def environment def environment
SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load" SharedHelpers.major_deprecation 3, "Bundler.environment has been removed in favor of Bundler.load"
load load
end end
@ -283,7 +283,7 @@ EOF
# @deprecated Use `original_env` instead # @deprecated Use `original_env` instead
# @return [Hash] Environment with all bundler-related variables removed # @return [Hash] Environment with all bundler-related variables removed
def clean_env def clean_env
Bundler::SharedHelpers.major_deprecation(2, "`Bundler.clean_env` has weird edge cases, use `.original_env` instead") Bundler::SharedHelpers.major_deprecation(3, "`Bundler.clean_env` has weird edge cases, use `.original_env` instead")
env = original_env env = original_env
if env.key?("BUNDLER_ORIG_MANPATH") if env.key?("BUNDLER_ORIG_MANPATH")

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/shared_helpers" require "bundler/shared_helpers"
Bundler::SharedHelpers.major_deprecation 2, Bundler::SharedHelpers.major_deprecation 3,
"The Bundler task for Capistrano. Please use http://github.com/capistrano/bundler" "The Bundler task for Capistrano. Please use http://github.com/capistrano/bundler"
# Capistrano task for Bundler. # Capistrano task for Bundler.

View file

@ -229,7 +229,7 @@ module Bundler
"Include gems that are part of the specified named group." "Include gems that are part of the specified named group."
map "i" => "install" map "i" => "install"
def install def install
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") SharedHelpers.major_deprecation(3, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
require "bundler/cli/install" require "bundler/cli/install"
Bundler.settings.temporary(:no_install => false) do Bundler.settings.temporary(:no_install => false) do
Install.new(options.dup).run Install.new(options.dup).run
@ -275,7 +275,7 @@ module Bundler
method_option "all", :type => :boolean, :banner => method_option "all", :type => :boolean, :banner =>
"Update everything." "Update everything."
def update(*gems) def update(*gems)
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") SharedHelpers.major_deprecation(3, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
require "bundler/cli/update" require "bundler/cli/update"
Update.new(options, gems).run Update.new(options, gems).run
end end
@ -303,7 +303,7 @@ module Bundler
old_argv = ARGV.join(" ") old_argv = ARGV.join(" ")
new_argv = [new_command, *new_arguments.compact].join(" ") new_argv = [new_command, *new_arguments.compact].join(" ")
Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") Bundler::SharedHelpers.major_deprecation(3, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`")
end end
require "bundler/cli/show" require "bundler/cli/show"
Show.new(options, gem_name).run Show.new(options, gem_name).run
@ -537,7 +537,7 @@ module Bundler
method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version." method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group." method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
def viz def viz
SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz" SharedHelpers.major_deprecation 3, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz"
require "bundler/cli/viz" require "bundler/cli/viz"
Viz.new(options.dup).run Viz.new(options.dup).run
end end
@ -608,7 +608,7 @@ module Bundler
method_option "group", :type => :string, :banner => method_option "group", :type => :string, :banner =>
"Install gem into a bundler group" "Install gem into a bundler group"
def inject(name, version) def inject(name, version)
SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command" SharedHelpers.major_deprecation 3, "The `inject` command has been replaced by the `add` command"
require "bundler/cli/inject" require "bundler/cli/inject"
Inject.new(options.dup, name, version).run Inject.new(options.dup, name, version).run
end end

View file

@ -9,7 +9,7 @@ module Bundler
end end
def run def run
Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \ Bundler::SharedHelpers.major_deprecation 3, "bundle console will be replaced " \
"by `bin/console` generated by `bundle gem <name>`" "by `bin/console` generated by `bundle gem <name>`"
group ? Bundler.require(:default, *(group.split.map!(&:to_sym))) : Bundler.require group ? Bundler.require(:default, *(group.split.map!(&:to_sym))) : Bundler.require

View file

@ -53,7 +53,7 @@ module Bundler
Bundler::Fetcher.disable_endpoint = options["full-index"] Bundler::Fetcher.disable_endpoint = options["full-index"]
if options["binstubs"] if options["binstubs"]
Bundler::SharedHelpers.major_deprecation 2, Bundler::SharedHelpers.major_deprecation 3,
"The --binstubs option will be removed in favor of `bundle binstubs`" "The --binstubs option will be removed in favor of `bundle binstubs`"
end end

View file

@ -22,7 +22,7 @@ module Bundler
if Bundler.feature_flag.update_requires_all_flag? if Bundler.feature_flag.update_requires_all_flag?
raise InvalidOption, "To update everything, pass the `--all` flag." raise InvalidOption, "To update everything, pass the `--all` flag."
end end
SharedHelpers.major_deprecation 2, "Pass --all to `bundle update` to update everything" SharedHelpers.major_deprecation 3, "Pass --all to `bundle update` to update everything"
elsif !full_update && options[:all] elsif !full_update && options[:all]
raise InvalidOption, "Cannot specify --all along with specific options." raise InvalidOption, "Cannot specify --all along with specific options."
end end

View file

@ -331,7 +331,7 @@ module Bundler
# i.e., Windows with `git config core.autocrlf=true` # i.e., Windows with `git config core.autocrlf=true`
contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n") contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
if @locked_bundler_version if @locked_bundler_version && Bundler.feature_flag.lockfile_upgrade_warning?
locked_major = @locked_bundler_version.segments.first locked_major = @locked_bundler_version.segments.first
current_major = Gem::Version.create(Bundler::VERSION).segments.first current_major = Gem::Version.create(Bundler::VERSION).segments.first

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/shared_helpers" require "bundler/shared_helpers"
Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \ Bundler::SharedHelpers.major_deprecation 3, "Bundler no longer integrates with " \
"Capistrano, but Capistrano provides its own integration with " \ "Capistrano, but Capistrano provides its own integration with " \
"Bundler via the capistrano-bundler gem. Use it instead." "Bundler via the capistrano-bundler gem. Use it instead."

View file

@ -194,7 +194,7 @@ module Bundler
" end\n\n" " end\n\n"
raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource? raise DeprecatedError, msg if Bundler.feature_flag.disable_multisource?
SharedHelpers.major_deprecation(2, msg.strip) SharedHelpers.major_deprecation(3, msg.strip)
end end
source_options = normalize_hash(options).merge( source_options = normalize_hash(options).merge(
@ -306,7 +306,7 @@ module Bundler
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
# TODO: 2.0 upgrade this setting to the default # TODO: 2.0 upgrade this setting to the default
if Bundler.settings["github.https"] if Bundler.settings["github.https"]
Bundler::SharedHelpers.major_deprecation 2, "The `github.https` setting will be removed" Bundler::SharedHelpers.major_deprecation 3, "The `github.https` setting will be removed"
"https://github.com/#{repo_name}.git" "https://github.com/#{repo_name}.git"
else else
"git://github.com/#{repo_name}.git" "git://github.com/#{repo_name}.git"
@ -456,7 +456,7 @@ repo_name ||= user_name
def normalize_source(source) def normalize_source(source)
case source case source
when :gemcutter, :rubygems, :rubyforge when :gemcutter, :rubygems, :rubyforge
Bundler::SharedHelpers.major_deprecation 2, "The source :#{source} is deprecated because HTTP " \ Bundler::SharedHelpers.major_deprecation 3, "The source :#{source} is deprecated because HTTP " \
"requests are insecure.\nPlease change your source to 'https://" \ "requests are insecure.\nPlease change your source to 'https://" \
"rubygems.org' if possible, or 'http://rubygems.org' if not." "rubygems.org' if possible, or 'http://rubygems.org' if not."
"http://rubygems.org" "http://rubygems.org"
@ -480,7 +480,7 @@ repo_name ||= user_name
end end
raise GemfileEvalError, msg raise GemfileEvalError, msg
else else
Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple primary sources. " \ Bundler::SharedHelpers.major_deprecation 3, "Your Gemfile contains multiple primary sources. " \
"Using `source` more than once without a block is a security risk, and " \ "Using `source` more than once without a block is a security risk, and " \
"may result in installing unexpected gems. To resolve this warning, use " \ "may result in installing unexpected gems. To resolve this warning, use " \
"a block to indicate which gems should come from the secondary source. " \ "a block to indicate which gems should come from the secondary source. " \
@ -498,7 +498,7 @@ repo_name ||= user_name
"do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end" "do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end"
end end
Bundler::SharedHelpers.major_deprecation 2, <<-EOS Bundler::SharedHelpers.major_deprecation 3, <<-EOS
The :#{name} git source is deprecated, and will be removed in Bundler 2.0.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work: The :#{name} git source is deprecated, and will be removed in Bundler 2.0.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work:
git_source(:#{name}) #{replacement} git_source(:#{name}) #{replacement}

View file

@ -44,6 +44,7 @@ module Bundler
settings_flag(:init_gems_rb) { bundler_3_mode? } settings_flag(:init_gems_rb) { bundler_3_mode? }
settings_flag(:list_command) { bundler_3_mode? } settings_flag(:list_command) { bundler_3_mode? }
settings_flag(:lockfile_uses_separate_rubygems_sources) { bundler_3_mode? } settings_flag(:lockfile_uses_separate_rubygems_sources) { bundler_3_mode? }
settings_flag(:lockfile_upgrade_warning) { bundler_3_mode? }
settings_flag(:only_update_to_newer_versions) { bundler_3_mode? } settings_flag(:only_update_to_newer_versions) { bundler_3_mode? }
settings_flag(:path_relative_to_cwd) { bundler_3_mode? } settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") } settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }

View file

@ -465,7 +465,7 @@ module Bundler
raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name ||= spec.default_executable raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name ||= spec.default_executable
unless spec.name == gem_name unless spec.name == gem_name
Bundler::SharedHelpers.major_deprecation 2, Bundler::SharedHelpers.major_deprecation 3,
"Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \ "Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \
"You should run `bundle binstub #{gem_name}` " \ "You should run `bundle binstub #{gem_name}` " \
"to work around a system/bundle conflict." "to work around a system/bundle conflict."

View file

@ -40,6 +40,7 @@ module Bundler
ignore_messages ignore_messages
init_gems_rb init_gems_rb
list_command list_command
lockfile_upgrade_warning
lockfile_uses_separate_rubygems_sources lockfile_uses_separate_rubygems_sources
major_deprecations major_deprecations
no_install no_install
@ -112,7 +113,7 @@ module Bundler
"bundle config #{key} #{Array(value).join(":")}" "bundle config #{key} #{Array(value).join(":")}"
end end
Bundler::SharedHelpers.major_deprecation 2,\ Bundler::SharedHelpers.major_deprecation 3,\
"flags passed to commands " \ "flags passed to commands " \
"will no longer be automatically remembered. Instead please set flags " \ "will no longer be automatically remembered. Instead please set flags " \
"you want remembered between commands using `bundle config " \ "you want remembered between commands using `bundle config " \

View file

@ -157,8 +157,8 @@ module Bundler
next if gemfiles.empty? next if gemfiles.empty?
break false if gemfiles.size == 1 break false if gemfiles.size == 1
end end
if multiple_gemfiles && Bundler.bundler_major_version == 1 if multiple_gemfiles && Bundler.bundler_major_version == 2
Bundler::SharedHelpers.major_deprecation 2, \ Bundler::SharedHelpers.major_deprecation 3, \
"gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock." "gems.rb and gems.locked will be preferred to Gemfile and Gemfile.lock."
end end

View file

@ -7,7 +7,7 @@ module Bundler
# We're doing this because we might write tests that deal # We're doing this because we might write tests that deal
# with other versions of bundler and we are unsure how to # with other versions of bundler and we are unsure how to
# handle this better. # handle this better.
VERSION = "1.17.1" unless defined?(::Bundler::VERSION) VERSION = "2.0.0.pre.1" unless defined?(::Bundler::VERSION)
def self.overwrite_loaded_gem_version def self.overwrite_loaded_gem_version
begin begin

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "bundler/shared_helpers" require "bundler/shared_helpers"
Bundler::SharedHelpers.major_deprecation 2, Bundler::SharedHelpers.major_deprecation 3,
"The Bundler task for Vlad" "The Bundler task for Vlad"
# Vlad task for Bundler. # Vlad task for Bundler.

View file

@ -21,7 +21,7 @@ RSpec.describe Bundler::UI::Shell do
describe "#warn" do describe "#warn" do
before { subject.level = "warn" } before { subject.level = "warn" }
it "prints to stdout", :bundler => "< 3" do it "prints to stdout", :bundler => "< 2" do
expect { subject.warn("warning") }.to output("warning\n").to_stdout expect { subject.warn("warning") }.to output("warning\n").to_stdout
end end
@ -46,7 +46,7 @@ RSpec.describe Bundler::UI::Shell do
describe "#error" do describe "#error" do
before { subject.level = "error" } before { subject.level = "error" }
it "prints to stdout", :bundler => "< 3" do it "prints to stdout", :bundler => "< 2" do
expect { subject.error("error!!!") }.to output("error!!!\n").to_stdout expect { subject.error("error!!!") }.to output("error!!!\n").to_stdout
end end

View file

@ -134,6 +134,33 @@ RSpec.describe "bundle binstubs <gem>" do
if ENV["BUNDLER_SPEC_SUB_VERSION"] if ENV["BUNDLER_SPEC_SUB_VERSION"]
let(:system_bundler_version) { Bundler::VERSION } let(:system_bundler_version) { Bundler::VERSION }
end end
before do
gemfile <<-G
source "file:///Users/colby/Projects/bundler/tmp/gems/remote2"
gem "rack"
gem "prints_loaded_gems"
G
lockfile <<-G
GEM
remote: file:///Users/colby/Projects/bundler/tmp/gems/remote2/
specs:
prints_loaded_gems (1.0)
rack (1.2)
PLATFORMS
ruby
DEPENDENCIES
prints_loaded_gems
rack
BUNDLED WITH
#{system_bundler_version}
G
end
it "runs bundler" do it "runs bundler" do
sys_exec! "#{bundled_app("bin/bundle")} install" sys_exec! "#{bundled_app("bin/bundle")} install"
expect(out).to eq %(system bundler #{system_bundler_version}\n["install"]) expect(out).to eq %(system bundler #{system_bundler_version}\n["install"])

View file

@ -142,7 +142,7 @@ RSpec.describe "bundle clean" do
bundle :clean bundle :clean
digest = Digest(:SHA1).hexdigest(git_path.to_s) digest = Digest(:SHA1).hexdigest(git_path.to_s)
cache_path = Bundler::VERSION.start_with?("1.") ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}") cache_path = Bundler.bundler_major_version < 3 ? vendored_gems("cache/bundler/git/foo-1.0-#{digest}") : home(".bundle/cache/git/foo-1.0-#{digest}")
expect(cache_path).to exist expect(cache_path).to exist
end end

View file

@ -570,22 +570,7 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs" it_behaves_like "it runs"
end end
context "the executable is empty", :bundler => "< 3" do context "the executable is empty" do
let(:executable) { "" }
let(:exit_code) { 0 }
let(:expected) { "#{path} is empty" }
let(:expected_err) { "" }
if LessThanProc.with(RUBY_VERSION).call("1.9")
# Kernel#exec in ruby < 1.9 will raise Errno::ENOEXEC if the command content is empty,
# even if the command is set as an executable.
pending "Kernel#exec is different"
else
it_behaves_like "it runs"
end
end
context "the executable is empty", :bundler => "3" do
let(:executable) { "" } let(:executable) { "" }
let(:exit_code) { 0 } let(:exit_code) { 0 }
@ -594,18 +579,7 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs" it_behaves_like "it runs"
end end
context "the executable raises", :bundler => "< 3" do context "the executable raises" do
let(:executable) { super() << "\nraise 'ERROR'" }
let(:exit_code) { 1 }
let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" }
let(:expected_err) do
"RuntimeError: ERROR\n #{path}:10" +
(Bundler.current_ruby.ruby_18? ? "" : ":in `<top (required)>'")
end
it_behaves_like "it runs"
end
context "the executable raises", :bundler => "3" do
let(:executable) { super() << "\nraise 'ERROR'" } let(:executable) { super() << "\nraise 'ERROR'" }
let(:exit_code) { 1 } let(:exit_code) { 1 }
let(:expected_err) do let(:expected_err) do
@ -615,16 +589,7 @@ RSpec.describe "bundle exec" do
it_behaves_like "it runs" it_behaves_like "it runs"
end end
context "the executable raises an error without a backtrace", :bundler => "< 3" do context "the executable raises an error without a backtrace" do
let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" }
let(:exit_code) { 1 }
let(:expected) { super() << "\nbundler: failed to load command: #{path} (#{path})" }
let(:expected_err) { "Err: Err" }
it_behaves_like "it runs"
end
context "the executable raises an error without a backtrace", :bundler => "3" do
let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" } let(:executable) { super() << "\nclass Err < Exception\ndef backtrace; end;\nend\nraise Err" }
let(:exit_code) { 1 } let(:exit_code) { 1 }
let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\nErr: Err" } let(:expected_err) { "bundler: failed to load command: #{path} (#{path})\nErr: Err" }

View file

@ -115,7 +115,7 @@ RSpec.describe "bundle init" do
bundle :init, :gemspec => spec_file bundle :init, :gemspec => spec_file
gemfile = if Bundler::VERSION[0, 2] == "1." gemfile = if Bundler::VERSION[0, 2].to_i < 3
bundled_app("Gemfile").read bundled_app("Gemfile").read
else else
bundled_app("gems.rb").read bundled_app("gems.rb").read

View file

@ -49,7 +49,7 @@ RSpec.describe "bundle pristine", :ruby_repo do
bundle! "pristine", :system_bundler => true bundle! "pristine", :system_bundler => true
bundle! "-v", :system_bundler => true bundle! "-v", :system_bundler => true
expected = if Bundler::VERSION < "2.0" expected = if Bundler::VERSION < "3.0"
"Bundler version" "Bundler version"
else else
Bundler::VERSION Bundler::VERSION

View file

@ -36,7 +36,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
it "prints path if gem exists in bundle" do it "prints path if gem exists in bundle" do
bundle "show rails" bundle "show rails"
expect(out).to eq( expect(out).to eq(
"[DEPRECATED FOR 2.0] use `bundle info rails` instead of `bundle show rails`\n" + "[DEPRECATED FOR 3.0] use `bundle info rails` instead of `bundle show rails`\n" +
default_bundle_path("gems", "rails-2.3.2").to_s default_bundle_path("gems", "rails-2.3.2").to_s
) )
end end
@ -44,7 +44,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
it "prints the path to the running bundler" do it "prints the path to the running bundler" do
bundle "show bundler" bundle "show bundler"
expect(out).to eq( expect(out).to eq(
"[DEPRECATED FOR 2.0] use `bundle info bundler` instead of `bundle show bundler`\n" + "[DEPRECATED FOR 3.0] use `bundle info bundler` instead of `bundle show bundler`\n" +
root.to_s root.to_s
) )
end end
@ -52,7 +52,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
it "prints path if gem exists in bundle (with --paths option)" do it "prints path if gem exists in bundle (with --paths option)" do
bundle "show rails --paths" bundle "show rails --paths"
expect(out).to eq( expect(out).to eq(
"[DEPRECATED FOR 2.0] use `bundle info rails --path` instead of `bundle show rails --paths`\n" + "[DEPRECATED FOR 3.0] use `bundle info rails --path` instead of `bundle show rails --paths`\n" +
default_bundle_path("gems", "rails-2.3.2").to_s default_bundle_path("gems", "rails-2.3.2").to_s
) )
end end
@ -64,7 +64,7 @@ RSpec.describe "bundle show", :bundler => "< 3", :ruby => ">= 2.0" do
expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s) expect(out).to include(default_bundle_path("gems", "rails-2.3.2").to_s)
out_lines = out.split("\n") out_lines = out.split("\n")
expect(out_lines[0]).to eq("[DEPRECATED FOR 2.0] use `bundle list` instead of `bundle show --paths`") expect(out_lines[0]).to eq("[DEPRECATED FOR 3.0] use `bundle list` instead of `bundle show --paths`")
# Gem names are the last component of their path. # Gem names are the last component of their path.
gem_list = out_lines[1..-1].map {|p| p.split("/").last } gem_list = out_lines[1..-1].map {|p| p.split("/").last }

View file

@ -297,7 +297,7 @@ RSpec.describe "install with --deployment or --frozen" do
context "when replacing a host with the same host with credentials" do context "when replacing a host with the same host with credentials" do
let(:success_message) do let(:success_message) do
if Bundler::VERSION.split(".", 2).first == "1" if Bundler.bundler_major_version < 3
"Could not reach host localgemserver.test" "Could not reach host localgemserver.test"
else else
"Bundle complete!" "Bundle complete!"

View file

@ -19,7 +19,7 @@ RSpec.describe "post bundle message" do
let(:bundle_complete_message) { "Bundle complete!" } let(:bundle_complete_message) { "Bundle complete!" }
let(:bundle_updated_message) { "Bundle updated!" } let(:bundle_updated_message) { "Bundle updated!" }
let(:installed_gems_stats) { "4 Gemfile dependencies, 5 gems now installed." } let(:installed_gems_stats) { "4 Gemfile dependencies, 5 gems now installed." }
let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 2 ? bundle_show_system_message : bundle_show_path_message } let(:bundle_show_message) { Bundler::VERSION.split(".").first.to_i < 3 ? bundle_show_system_message : bundle_show_path_message }
describe "for fresh bundle install" do describe "for fresh bundle install" do
it "without any options" do it "without any options" do

View file

@ -65,12 +65,12 @@ RSpec.describe "bundle install", :bundler => "< 3", :ruby => ">= 2.0" do
it "shows a deprecation when single flag passed" do it "shows a deprecation when single flag passed" do
bundle! "install --force" bundle! "install --force"
expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
end end
it "shows a deprecation when multiple flags passed" do it "shows a deprecation when multiple flags passed" do
bundle! "install --no-color --force" bundle! "install --no-color --force"
expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
end end
end end

View file

@ -205,7 +205,7 @@ The :github git source is deprecated, and will be removed in Bundler 2.0. Change
git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
EOS EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
subject.gem("sparks", :github => "indirect/sparks") subject.gem("sparks", :github => "indirect/sparks")
end end
@ -217,8 +217,8 @@ The :github git source is deprecated, and will be removed in Bundler 2.0. Change
git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" } git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
EOS EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, "The `github.https` setting will be removed") expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, "The `github.https` setting will be removed")
subject.gem("sparks", :github => "indirect/sparks") subject.gem("sparks", :github => "indirect/sparks")
github_uri = "https://github.com/indirect/sparks.git" github_uri = "https://github.com/indirect/sparks.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri) expect(subject.dependencies.first.source.uri).to eq(github_uri)
@ -238,7 +238,7 @@ The :bitbucket git source is deprecated, and will be removed in Bundler 2.0. Add
end end
EOS EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails") subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
end end
end end
@ -250,7 +250,7 @@ The :bitbucket git source is deprecated, and will be removed in Bundler 2.0. Add
"in Bundler 2.0. Add this code to the top of your Gemfile to ensure it " \ "in Bundler 2.0. Add this code to the top of your Gemfile to ensure it " \
"continues to work:\n\n git_source(:gist) {|repo_name| " \ "continues to work:\n\n git_source(:gist) {|repo_name| " \
"\"https://gist.github.com/\#{repo_name}.git\" }\n\n" "\"https://gist.github.com/\#{repo_name}.git\" }\n\n"
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, msg) expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(3, msg)
subject.gem("not-really-a-gem", :gist => "1234") subject.gem("not-really-a-gem", :gist => "1234")
end end
end end

View file

@ -4,7 +4,7 @@ RSpec.describe "bundle platform" do
context "without flags" do context "without flags" do
let(:bundle_platform_platforms_string) do let(:bundle_platform_platforms_string) do
platforms = [rb] platforms = [rb]
platforms.unshift(specific_local_platform) if Bundler.feature_flag.bundler_2_mode? platforms.unshift(specific_local_platform) if Bundler.feature_flag.bundler_3_mode?
platforms.map {|pl| "* #{pl}" }.join("\n") platforms.map {|pl| "* #{pl}" }.join("\n")
end end

View file

@ -181,6 +181,7 @@ RSpec.describe "The library itself" do
gem.coc gem.coc
gem.mit gem.mit
inline inline
lockfile_upgrade_warning
lockfile_uses_separate_rubygems_sources lockfile_uses_separate_rubygems_sources
use_gem_version_promoter_for_major_updates use_gem_version_promoter_for_major_updates
viz_command viz_command

View file

@ -57,7 +57,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
expect(lockfile).to include("activemodel (3.0.5)") expect(lockfile).to include("activemodel (3.0.5)")
end end
it "resolves dependencies correctly", :ruby => "1.9.3" do it "resolves dependencies correctly", :ruby => "<= 1.9.3" do
gemfile <<-G gemfile <<-G
source "https://rubygems.org" source "https://rubygems.org"
@ -70,7 +70,7 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
expect(lockfile).to include("capybara (2.2.1)") expect(lockfile).to include("capybara (2.2.1)")
end end
it "installs the latest version of gxapi_rails", :ruby => "1.9.3" do it "installs the latest version of gxapi_rails", :ruby => "<= 1.9.3" do
gemfile <<-G gemfile <<-G
source "https://rubygems.org" source "https://rubygems.org"

View file

@ -19,7 +19,7 @@ RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do
it "includes the relevant tasks" do it "includes the relevant tasks" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec "ruby -S rake -T" sys_exec "#{rake} -T"
end end
expect(err).to eq("") expect(err).to eq("")
@ -37,7 +37,7 @@ RSpec.describe "require 'bundler/gem_tasks'", :ruby_repo do
it "adds 'pkg' to rake/clean's CLOBBER" do it "adds 'pkg' to rake/clean's CLOBBER" do
with_gem_path_as(Spec::Path.base_system_gems.to_s) do with_gem_path_as(Spec::Path.base_system_gems.to_s) do
sys_exec! %('#{Gem.ruby}' -S rake -e 'load "Rakefile"; puts CLOBBER.inspect') sys_exec! %(#{rake} -e 'load "Rakefile"; puts CLOBBER.inspect')
end end
expect(last_command.stdout).to eq '["pkg"]' expect(last_command.stdout).to eq '["pkg"]'
end end

View file

@ -53,7 +53,7 @@ module Spec
end end
def bundle_update_requires_all? def bundle_update_requires_all?
Bundler::VERSION.start_with?("1.") ? nil : true Bundler::VERSION.start_with?("2.") ? nil : true
end end
def in_app_root(&blk) def in_app_root(&blk)
@ -152,7 +152,7 @@ module Spec
bang :bundle bang :bundle
def forgotten_command_line_options(options) def forgotten_command_line_options(options)
remembered = Bundler::VERSION.split(".", 2).first == "1" remembered = Bundler.bundler_major_version < 3
options = options.map do |k, v| options = options.map do |k, v|
k = Array(k)[remembered ? 0 : -1] k = Array(k)[remembered ? 0 : -1]
v = '""' if v && v.to_s.empty? v = '""' if v && v.to_s.empty?

View file

@ -29,7 +29,7 @@ module Spec
end end
def default_bundle_path(*path) def default_bundle_path(*path)
if Bundler::VERSION.split(".").first.to_i < 2 if Bundler::VERSION.split(".").first.to_i < 3
system_gem_path(*path) system_gem_path(*path)
else else
bundled_app(*[".bundle", ENV.fetch("BUNDLER_SPEC_RUBY_ENGINE", Gem.ruby_engine), Gem::ConfigMap[:ruby_version], *path].compact) bundled_app(*[".bundle", ENV.fetch("BUNDLER_SPEC_RUBY_ENGINE", Gem.ruby_engine), Gem::ConfigMap[:ruby_version], *path].compact)

View file

@ -106,7 +106,7 @@ module Spec
end end
def local_platforms def local_platforms
if Bundler::VERSION.split(".").first.to_i > 1 if Bundler::VERSION.split(".").first.to_i > 2
[local, specific_local_platform] [local, specific_local_platform]
else else
[local] [local]

View file

@ -33,7 +33,7 @@ module Spec
ENV["BUNDLE_PATH"] = nil ENV["BUNDLE_PATH"] = nil
ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s ENV["GEM_HOME"] = ENV["GEM_PATH"] = Path.base_system_gems.to_s
ENV["PATH"] = ["#{Path.root}/exe", "#{Path.system_gem_path}/bin", ENV["PATH"]].join(File::PATH_SEPARATOR) ENV["PATH"] = [Path.bindir, "#{Path.system_gem_path}/bin", ENV["PATH"]].join(File::PATH_SEPARATOR)
manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" } manifest = DEPS.to_a.sort_by(&:first).map {|k, v| "#{k} => #{v}\n" }
manifest_path = "#{Path.base_system_gems}/manifest.txt" manifest_path = "#{Path.base_system_gems}/manifest.txt"

View file

@ -13,24 +13,24 @@ RSpec.describe "bundle update", :bundler => "< 3", :ruby => ">= 2.0" do
describe "with --force" do describe "with --force" do
it "shows a deprecation when single flag passed" do it "shows a deprecation when single flag passed" do
bundle! "update rack --force" bundle! "update rack --force"
expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
end end
it "shows a deprecation when multiple flags passed" do it "shows a deprecation when multiple flags passed" do
bundle! "update rack --no-color --force" bundle! "update rack --no-color --force"
expect(out).to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" expect(out).to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
end end
end end
describe "with --redownload" do describe "with --redownload" do
it "does not show a deprecation when single flag passed" do it "does not show a deprecation when single flag passed" do
bundle! "update rack --redownload" bundle! "update rack --redownload"
expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
end end
it "does not show a deprecation when single multiple flags passed" do it "does not show a deprecation when single multiple flags passed" do
bundle! "update rack --no-color --redownload" bundle! "update rack --no-color --redownload"
expect(out).not_to include "[DEPRECATED FOR 2.0] The `--force` option has been renamed to `--redownload`" expect(out).not_to include "[DEPRECATED FOR 3.0] The `--force` option has been renamed to `--redownload`"
end end
end end
end end