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

Merge Bundler-2.2.5

This commit is contained in:
Hiroshi SHIBATA 2021-01-14 13:38:17 +09:00 committed by NARUSE, Yui
parent c721e36cec
commit 93dcf0828d
26 changed files with 240 additions and 112 deletions

View file

@ -63,7 +63,6 @@ module Bundler
autoload :Resolver, File.expand_path("bundler/resolver", __dir__)
autoload :Retry, File.expand_path("bundler/retry", __dir__)
autoload :RubyDsl, File.expand_path("bundler/ruby_dsl", __dir__)
autoload :RubyGemsGemInstaller, File.expand_path("bundler/rubygems_gem_installer", __dir__)
autoload :RubyVersion, File.expand_path("bundler/ruby_version", __dir__)
autoload :Runtime, File.expand_path("bundler/runtime", __dir__)
autoload :Settings, File.expand_path("bundler/settings", __dir__)

View file

@ -59,6 +59,7 @@ module Bundler
:exe => options[:exe],
:bundler_version => bundler_dependency_version,
:github_username => github_username.empty? ? "[USERNAME]" : github_username,
:required_ruby_version => Gem.ruby_version < Gem::Version.new("2.4.a") ? "2.3.0" : "2.4.0",
}
ensure_safe_gem_name(name, constant_array)
@ -147,6 +148,7 @@ module Bundler
"For more information, see the RuboCop docs (https://docs.rubocop.org/en/stable/) " \
"and the Ruby Style Guides (https://github.com/rubocop-hq/ruby-style-guide).")
config[:rubocop] = true
config[:rubocop_version] = Gem.ruby_version < Gem::Version.new("2.4.a") ? "0.81.0" : "1.7"
Bundler.ui.info "RuboCop enabled in config"
templates.merge!("rubocop.yml.tt" => ".rubocop.yml")
end

View file

@ -1,8 +1,6 @@
# frozen_string_literal: true
require_relative "../vendored_fileutils"
require "stringio"
require "zlib"
module Bundler
class CompactIndexClient
@ -45,18 +43,12 @@ module Bundler
else
"bytes=#{local_temp_path.size}-"
end
else
# Fastly ignores Range when Accept-Encoding: gzip is set
headers["Accept-Encoding"] = "gzip"
end
response = @fetcher.call(remote_path, headers)
return nil if response.is_a?(Net::HTTPNotModified)
content = response.body
if response["Content-Encoding"] == "gzip"
content = Zlib::GzipReader.new(StringIO.new(content)).read
end
SharedHelpers.filesystem_access(local_temp_path) do
if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?

View file

@ -117,13 +117,13 @@ module Bundler
def git_push(remote = nil)
remote ||= default_remote
perform_git_push remote
perform_git_push "#{remote} #{version_tag}"
perform_git_push "#{remote} refs/tags/#{version_tag}"
Bundler.ui.confirm "Pushed git commits and release tag."
end
def default_remote
current_branch = sh(%w[git rev-parse --abbrev-ref HEAD]).strip
return "origin" if current_branch.empty?
# We can replace this with `git branch --show-current` once we drop support for git < 2.22.0
current_branch = sh(%w[git rev-parse --abbrev-ref HEAD]).gsub(%r{\Aheads/}, "").strip
remote_for_branch = sh(%W[git config --get branch.#{current_branch}.remote]).strip
return "origin" if remote_for_branch.empty?

View file

@ -163,7 +163,12 @@ module Bundler
# Add a spec group for "non platform specific spec" as the fallback
# spec group.
sg_ruby = sg.copy_for([Gem::Platform::RUBY])
selected_sgs.insert(-2, sg_ruby) if sg_ruby
next unless sg_ruby
sg_ruby_deps = sg_ruby.dependencies_for_activated_platforms.map(&:dep)
sg_all_platforms_deps = sg_all_platforms.dependencies_for_activated_platforms.map(&:dep)
selected_sgs.insert(-2, sg_ruby) if sg_ruby_deps != sg_all_platforms_deps
end
selected_sgs
end

View file

@ -22,7 +22,7 @@ module Bundler
@uri = options["uri"] || ""
@safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
@branch = options["branch"]
@ref = options["ref"] || options["branch"] || options["tag"] || "master"
@ref = options["ref"] || options["branch"] || options["tag"]
@submodules = options["submodules"]
@name = options["name"]
@version = options["version"].to_s.strip.gsub("-", ".pre.")
@ -60,25 +60,27 @@ module Bundler
alias_method :==, :eql?
def to_s
at = if local?
path
elsif user_ref = options["ref"]
if ref =~ /\A[a-z0-9]{4,}\z/i
shortref_for_display(user_ref)
begin
at = if local?
path
elsif user_ref = options["ref"]
if ref =~ /\A[a-z0-9]{4,}\z/i
shortref_for_display(user_ref)
else
user_ref
end
elsif ref
ref
else
user_ref
git_proxy.branch
end
else
ref
rev = " (at #{at}@#{shortref_for_display(revision)})"
rescue GitError
""
end
rev = begin
"@#{shortref_for_display(revision)}"
rescue GitError
nil
end
"#{@safe_uri} (at #{at}#{rev})"
"#{@safe_uri}#{rev}"
end
def name

View file

@ -17,7 +17,7 @@ module Bundler
class GitNotAllowedError < GitError
def initialize(command)
msg = String.new
msg << "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, "
msg << "Bundler is trying to run `#{command}` at runtime. You probably need to run `bundle install`. However, "
msg << "this error message could probably be more useful. Please submit a ticket at https://github.com/rubygems/rubygems/issues/new?labels=Bundler&template=bundler-related-issue.md "
msg << "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}"
super msg
@ -27,11 +27,11 @@ module Bundler
class GitCommandError < GitError
attr_reader :command
def initialize(command, path, destination_path, extra_info = nil)
def initialize(command, path, extra_info = nil)
@command = command
msg = String.new
msg << "Git error: command `git #{command}` in directory #{destination_path} has failed."
msg << "Git error: command `#{command}` in directory #{path} has failed."
msg << "\n#{extra_info}" if extra_info
msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path.exist?
super msg
@ -39,9 +39,9 @@ module Bundler
end
class MissingGitRevisionError < GitCommandError
def initialize(command, path, destination_path, ref, repo)
def initialize(command, destination_path, ref, repo)
msg = "Revision #{ref} does not exist in the repository #{repo}. Maybe you misspelled it?"
super command, path, destination_path, msg
super command, destination_path, msg
end
end
@ -132,7 +132,7 @@ module Bundler
begin
git "reset", "--hard", @revision, :dir => destination
rescue GitCommandError => e
raise MissingGitRevisionError.new(e.command, path, destination, @revision, URICredentialsFilter.credential_filtered_uri(uri))
raise MissingGitRevisionError.new(e.command, destination, @revision, URICredentialsFilter.credential_filtered_uri(uri))
end
if submodules
@ -145,32 +145,36 @@ module Bundler
private
def git_null(*command, dir: SharedHelpers.pwd)
def git_null(*command, dir: nil)
check_allowed(command)
out, status = SharedHelpers.with_clean_git_env do
capture_and_ignore_stderr("git", "-C", dir.to_s, *command)
capture_and_ignore_stderr(*capture3_args_for(command, dir))
end
[URICredentialsFilter.credential_filtered_string(out, uri), status]
end
def git_retry(*command, dir: SharedHelpers.pwd)
Bundler::Retry.new("`git -C #{dir} #{URICredentialsFilter.credential_filtered_string(command.shelljoin, uri)}`", GitNotAllowedError).attempts do
def git_retry(*command, dir: nil)
command_with_no_credentials = check_allowed(command)
Bundler::Retry.new("`#{command_with_no_credentials}` at #{dir || SharedHelpers.pwd}").attempts do
git(*command, :dir => dir)
end
end
def git(*command, dir: SharedHelpers.pwd)
def git(*command, dir: nil)
command_with_no_credentials = check_allowed(command)
out, status = SharedHelpers.with_clean_git_env do
capture_and_filter_stderr("git", "-C", dir.to_s, *command)
capture_and_filter_stderr(*capture3_args_for(command, dir))
end
raise GitCommandError.new(command_with_no_credentials, path, dir) unless status.success?
filtered_out = URICredentialsFilter.credential_filtered_string(out, uri)
URICredentialsFilter.credential_filtered_string(out, uri)
raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, filtered_out) unless status.success?
filtered_out
end
def has_revision_cached?
@ -187,10 +191,10 @@ module Bundler
def find_local_revision
allowed_with_path do
git("rev-parse", "--verify", ref, :dir => path).strip
git("rev-parse", "--verify", ref || "HEAD", :dir => path).strip
end
rescue GitCommandError => e
raise MissingGitRevisionError.new(e.command, path, path, ref, URICredentialsFilter.credential_filtered_uri(uri))
raise MissingGitRevisionError.new(e.command, path, ref, URICredentialsFilter.credential_filtered_uri(uri))
end
# Adds credentials to the URI as Fetcher#configured_uri_for does
@ -220,7 +224,7 @@ module Bundler
end
def check_allowed(command)
command_with_no_credentials = URICredentialsFilter.credential_filtered_string(command.shelljoin, uri)
command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
command_with_no_credentials
end
@ -237,6 +241,20 @@ module Bundler
return_value, _, status = Open3.capture3(*cmd)
[return_value, status]
end
def capture3_args_for(cmd, dir)
return ["git", *cmd] unless dir
if Bundler.feature_flag.bundler_3_mode? || supports_minus_c?
["git", "-C", dir.to_s, *cmd]
else
["git", *cmd, { :chdir => dir.to_s }]
end
end
def supports_minus_c?
@supports_minus_c ||= Gem::Version.new(version) >= Gem::Version.new("1.8.5")
end
end
end
end

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
require_relative "../../rubygems_gem_installer"
module Bundler
class Source
class Path

View file

@ -145,6 +145,8 @@ module Bundler
Bundler.mkdir_p bin_path, :no_sudo => true unless spec.executables.empty? || Bundler.rubygems.provides?(">= 2.7.5")
require_relative "../rubygems_gem_installer"
installed_spec = Bundler::RubyGemsGemInstaller.at(
path,
:install_dir => install_path.to_s,
@ -487,8 +489,15 @@ module Bundler
uri = spec.remote.uri
Bundler.ui.confirm("Fetching #{version_message(spec)}")
rubygems_local_path = Bundler.rubygems.download_gem(spec, uri, download_path)
# older rubygems return varying file:// variants depending on version
rubygems_local_path = rubygems_local_path.gsub(/\Afile:/, "") unless Bundler.rubygems.provides?(">= 3.2.0.rc.2")
rubygems_local_path = rubygems_local_path.gsub(%r{\A//}, "") if Bundler.rubygems.provides?("< 3.1.0")
if rubygems_local_path != local_path
FileUtils.mv(rubygems_local_path, local_path)
SharedHelpers.filesystem_access(local_path) do
FileUtils.mv(rubygems_local_path, local_path)
end
end
cache_globally(spec, local_path)
end

View file

@ -16,5 +16,5 @@ gem "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>"
<%- end -%>
<%- if config[:rubocop] -%>
gem "rubocop", "~> 0.80"
gem "rubocop", "~> <%= config[:rubocop_version] %>"
<%- end -%>

View file

@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
<%- if config[:mit] -%>
spec.license = "MIT"
<%- end -%>
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
spec.required_ruby_version = Gem::Requirement.new(">= <%= config[:required_ruby_version] %>")
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"

View file

@ -1,3 +1,6 @@
AllCops:
TargetRubyVersion: <%= ::Gem::Version.new(config[:required_ruby_version]).segments[0..1].join(".") %>
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes

View file

@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
VERSION = "2.2.4".freeze
VERSION = "2.2.5".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i

View file

@ -17,7 +17,6 @@ RSpec.describe Bundler::CompactIndexClient::Updater do
let(:response) { double(:response, :body => "abc123") }
it "treats the response as an update" do
expect(response).to receive(:[]).with("Content-Encoding") { "" }
expect(response).to receive(:[]).with("ETag") { nil }
expect(fetcher).to receive(:call) { response }
@ -29,8 +28,7 @@ RSpec.describe Bundler::CompactIndexClient::Updater do
let(:response) { double(:response, :body => "") }
it "raises HTTPError" do
expect(response).to receive(:[]).with("Content-Encoding") { "gzip" }
expect(fetcher).to receive(:call) { response }
expect(fetcher).to receive(:call).and_raise(Zlib::GzipFile::Error)
expect do
updater.update(local_path, remote_path)

View file

@ -256,6 +256,16 @@ RSpec.describe Bundler::GemHelper do
Rake.application["release"].invoke
end
it "also works when releasing from an ambiguous reference" do
# Create a branch with the same name as the tag
sys_exec("git checkout -b v#{app_version}", :dir => app_path)
sys_exec("git push -u origin v#{app_version}", :dir => app_path)
expect(subject).to receive(:rubygem_push).with(app_gem_path.to_s)
Rake.application["release"].invoke
end
end
context "on releasing with a custom tag prefix" do

View file

@ -130,18 +130,20 @@ RSpec.describe Bundler::Source::Git::GitProxy do
context "when given a SHA as a revision" do
let(:revision) { "abcd" * 10 }
let(:command) { ["reset", "--hard", revision] }
let(:command_for_display) { "git #{command.shelljoin}" }
it "fails gracefully when resetting to the revision fails" do
expect(subject).to receive(:git_retry).with("clone", any_args) { destination.mkpath }
expect(subject).to receive(:git_retry).with("fetch", any_args, :dir => destination)
expect(subject).to receive(:git).with(*command, :dir => destination).and_raise(Bundler::Source::Git::GitCommandError.new(command, cache, destination))
expect(subject).to receive(:git).with(*command, :dir => destination).and_raise(Bundler::Source::Git::GitCommandError.new(command_for_display, destination))
expect(subject).not_to receive(:git)
expect { subject.copy_to(destination, submodules) }.
to raise_error(
Bundler::Source::Git::MissingGitRevisionError,
"Git error: command `git #{command}` in directory #{destination} has failed.\n" \
"Revision #{revision} does not exist in the repository #{uri}. Maybe you misspelled it?" \
"Git error: command `#{command_for_display}` in directory #{destination} has failed.\n" \
"Revision #{revision} does not exist in the repository #{uri}. Maybe you misspelled it?\n" \
"If this error persists you could try removing the cache directory '#{destination}'"
)
end
end

View file

@ -14,14 +14,14 @@ RSpec.describe Bundler::Source::Git do
describe "#to_s" do
it "returns a description" do
expect(subject.to_s).to eq "https://github.com/foo/bar.git (at master)"
expect(subject.to_s).to eq "https://github.com/foo/bar.git"
end
context "when the URI contains credentials" do
let(:uri) { "https://my-secret-token:x-oauth-basic@github.com/foo/bar.git" }
it "filters credentials" do
expect(subject.to_s).to eq "https://x-oauth-basic@github.com/foo/bar.git (at master)"
expect(subject.to_s).to eq "https://x-oauth-basic@github.com/foo/bar.git"
end
end
end

View file

@ -580,8 +580,10 @@ RSpec.describe "bundle install with gem sources" do
end
describe "when bundle path does not have write access", :permissions do
let(:bundle_path) { bundled_app("vendor") }
before do
FileUtils.mkdir_p(bundled_app("vendor"))
FileUtils.mkdir_p(bundle_path)
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
@ -589,11 +591,32 @@ RSpec.describe "bundle install with gem sources" do
end
it "should display a proper message to explain the problem" do
FileUtils.chmod(0o500, bundled_app("vendor"))
FileUtils.chmod(0o500, bundle_path)
bundle "config set --local path vendor"
bundle :install, :raise_on_error => false
expect(err).to include(bundle_path.to_s)
expect(err).to include("grant write permissions")
end
end
describe "when bundle cache path does not have write access", :permissions do
let(:cache_path) { bundled_app("vendor/#{Bundler.ruby_scope}/cache") }
before do
FileUtils.mkdir_p(cache_path)
gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem 'rack'
G
end
it "should display a proper message to explain the problem" do
FileUtils.chmod(0o500, cache_path)
bundle "config --local path vendor"
bundle :install, :raise_on_error => false
expect(err).to include(bundled_app("vendor").to_s)
expect(err).to include(cache_path.to_s)
expect(err).to include("grant write permissions")
end
end

View file

@ -12,10 +12,10 @@ RSpec.describe "bundle gem" do
def bundle_exec_rubocop
prepare_gemspec(bundled_app(gem_name, "#{gem_name}.gemspec"))
rubocop_version = RUBY_VERSION > "2.4" ? "0.90.0" : "0.80.1"
rubocop_version = RUBY_VERSION > "2.4" ? "1.7.0" : "0.81.0"
gems = ["minitest", "rake", "rake-compiler", "rspec", "rubocop -v #{rubocop_version}", "test-unit"]
gems.unshift "parallel -v 1.19.2" if RUBY_VERSION < "2.5"
gems += ["rubocop-ast -v 0.4.0"] if rubocop_version == "0.90.0"
gems += ["rubocop-ast -v 1.4.0"] if rubocop_version == "1.7.0"
path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(:base => bundled_app(gem_name)) : system_gem_path
realworld_system_gems gems, :path => path
bundle "exec rubocop --debug --config .rubocop.yml", :dir => bundled_app(gem_name)
@ -416,9 +416,7 @@ RSpec.describe "bundle gem" do
it "sets a minimum ruby version" do
bundle "gem #{gem_name}"
bundler_gemspec = Bundler::GemHelper.new(gemspec_dir).gemspec
expect(bundler_gemspec.required_ruby_version).to eq(generated_gemspec.required_ruby_version)
expect(generated_gemspec.required_ruby_version).to eq(Gem::Requirement.new(Gem.ruby_version < Gem::Version.new("2.4.a") ? ">= 2.3.0" : ">= 2.4.0"))
end
it "requires the version file" do

View file

@ -341,7 +341,7 @@ RSpec.describe "install in deployment or frozen mode" do
bundle "config --local deployment true"
bundle :install, :raise_on_error => false
expect(err).to include("deployment mode")
expect(err).to include("You have added to the Gemfile:\n* source: git://hubz.com (at master)")
expect(err).to include("You have added to the Gemfile:\n* source: git://hubz.com")
expect(err).not_to include("You have changed in the Gemfile")
end
@ -361,7 +361,7 @@ RSpec.describe "install in deployment or frozen mode" do
bundle "config --local deployment true"
bundle :install, :raise_on_error => false
expect(err).to include("deployment mode")
expect(err).to include("You have deleted from the Gemfile:\n* source: #{lib_path("rack-1.0")} (at master@#{revision_for(lib_path("rack-1.0"))[0..6]}")
expect(err).to include("You have deleted from the Gemfile:\n* source: #{lib_path("rack-1.0")}")
expect(err).not_to include("You have added to the Gemfile")
expect(err).not_to include("You have changed in the Gemfile")
end
@ -385,7 +385,7 @@ RSpec.describe "install in deployment or frozen mode" do
bundle "config --local deployment true"
bundle :install, :raise_on_error => false
expect(err).to include("deployment mode")
expect(err).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `#{lib_path("rack")} (at master@#{revision_for(lib_path("rack"))[0..6]})`")
expect(err).to include("You have changed in the Gemfile:\n* rack from `no specified source` to `#{lib_path("rack")}`")
expect(err).not_to include("You have added to the Gemfile")
expect(err).not_to include("You have deleted from the Gemfile")
end

View file

@ -142,10 +142,13 @@ RSpec.describe "bundle install with install-time dependencies" do
gem "net_e"
G
bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1" }
bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1", "DEBUG" => "1" }
activated_groups = "net_b (1.0) (ruby)"
activated_groups += ", net_b (1.0) (#{local_platforms.join(", ")})" if local_platforms.any? && local_platforms != ["ruby"]
activated_groups = if local_platforms.any?
"net_b (1.0) (#{local_platforms.join(", ")})"
else
"net_b (1.0) (ruby)"
end
expect(out).to include(" net_b").
and include("BUNDLER: Starting resolution").
@ -239,7 +242,7 @@ RSpec.describe "bundle install with install-time dependencies" do
let(:ruby_requirement) { %("#{RUBY_VERSION}") }
let(:error_message_requirement) { "~> #{RUBY_VERSION}.0" }
let(:error_message_platform) { " #{Bundler.local_platform}" }
let(:error_message_platform) { Bundler.local_platform }
shared_examples_for "ruby version conflicts" do
it "raises an error during resolution" do
@ -256,10 +259,10 @@ RSpec.describe "bundle install with install-time dependencies" do
nice_error = strip_whitespace(<<-E).strip
Bundler found conflicting requirements for the Ruby\0 version:
In Gemfile:
Ruby\0 (#{error_message_requirement})#{error_message_platform}
Ruby\0 (#{error_message_requirement}) #{error_message_platform}
require_ruby#{error_message_platform} was resolved to 1.0, which depends on
Ruby\0 (> 9000)
require_ruby #{error_message_platform} was resolved to 1.0, which depends on
Ruby\0 (> 9000) #{error_message_platform}
Ruby\0 (> 9000), which is required by gem 'require_ruby', is not available in the local ruby installation
E

View file

@ -2,10 +2,10 @@
RSpec.describe "bundle install" do
context "git sources" do
it "displays the revision hash of the gem repository", :bundler => "< 3" do
it "displays the revision hash of the gem repository" do
build_git "foo", "1.0", :path => lib_path("foo")
install_gemfile <<-G
install_gemfile <<-G, :verbose => true
gem "foo", :git => "#{file_uri_for(lib_path("foo"))}"
G
@ -13,7 +13,18 @@ RSpec.describe "bundle install" do
expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
end
it "displays the ref of the gem repository when using branch~num as a ref", :bundler => "< 3" do
it "displays the correct default branch" do
build_git "foo", "1.0", :path => lib_path("foo"), :default_branch => "main"
install_gemfile <<-G, :verbose => true
gem "foo", :git => "#{file_uri_for(lib_path("foo"))}"
G
expect(out).to include("Using foo 1.0 from #{file_uri_for(lib_path("foo"))} (at main@#{revision_for(lib_path("foo"))[0..6]})")
expect(the_bundle).to include_gems "foo 1.0", :source => "git@#{lib_path("foo")}"
end
it "displays the ref of the gem repository when using branch~num as a ref" do
skip "maybe branch~num notation doesn't work on Windows' git" if Gem.win_platform?
build_git "foo", "1.0", :path => lib_path("foo")
@ -22,7 +33,7 @@ RSpec.describe "bundle install" do
rev2 = revision_for(lib_path("foo"))[0..6]
update_git "foo", "3.0", :path => lib_path("foo"), :gemspec => true
install_gemfile <<-G
install_gemfile <<-G, :verbose => true
gem "foo", :git => "#{file_uri_for(lib_path("foo"))}", :ref => "master~2"
G
@ -31,7 +42,7 @@ RSpec.describe "bundle install" do
update_git "foo", "4.0", :path => lib_path("foo"), :gemspec => true
bundle :update, :all => true
bundle :update, :all => true, :verbose => true
expect(out).to include("Using foo 2.0 (was 1.0) from #{file_uri_for(lib_path("foo"))} (at master~2@#{rev2})")
expect(the_bundle).to include_gems "foo 2.0", :source => "git@#{lib_path("foo")}"
end

View file

@ -1134,7 +1134,7 @@ RSpec.describe "the lockfile format" do
G
expect(bundled_app_lock).not_to exist
expect(err).to include "rack (>= 0) should come from an unspecified source and git://hubz.com (at master)"
expect(err).to include "rack (>= 0) should come from an unspecified source and git://hubz.com"
end
it "works correctly with multiple version dependencies" do

View file

@ -451,9 +451,35 @@ RSpec.describe "real world edgecases", :realworld => true, :sometimes => true do
bundle :lock, :env => { "DEBUG_RESOLVER" => "1" }
if Bundler.feature_flag.bundler_3_mode?
expect(out).to include("BUNDLER: Finished resolution (2492 steps)")
expect(out).to include("BUNDLER: Finished resolution (1336 steps)")
else
expect(out).to include("BUNDLER: Finished resolution (2722 steps)")
expect(out).to include("BUNDLER: Finished resolution (1395 steps)")
end
end
it "doesn't hang on tricky gemfile" do
skip "Only for ruby 2.7.2" if RUBY_VERSION != "2.7.2"
gemfile <<~G
source 'https://rubygems.org'
group :development do
gem "puppet-module-posix-default-r2.7", '~> 0.3'
gem "puppet-module-posix-dev-r2.7", '~> 0.3'
gem "beaker-rspec"
gem "beaker-puppet"
gem "beaker-docker"
gem "beaker-puppet_install_helper"
gem "beaker-module_install_helper"
end
G
bundle :lock, :env => { "DEBUG_RESOLVER" => "1" }
if Bundler.feature_flag.bundler_3_mode?
expect(out).to include("BUNDLER: Finished resolution (366 steps)")
else
expect(out).to include("BUNDLER: Finished resolution (372 steps)")
end
end
end

View file

@ -12,7 +12,7 @@ RSpec.describe "Bundler.setup" do
G
ruby <<-RUBY
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup
require 'rack'
@ -34,7 +34,7 @@ RSpec.describe "Bundler.setup" do
it "doesn't make all groups available" do
ruby <<-RUBY
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup(:default)
begin
@ -49,7 +49,7 @@ RSpec.describe "Bundler.setup" do
it "accepts string for group name" do
ruby <<-RUBY
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup(:default, 'test')
require 'rack'
@ -61,7 +61,7 @@ RSpec.describe "Bundler.setup" do
it "leaves all groups available if they were already" do
ruby <<-RUBY
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup
Bundler.setup(:default)
@ -74,7 +74,7 @@ RSpec.describe "Bundler.setup" do
it "leaves :default available if setup is called twice" do
ruby <<-RUBY
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup(:default)
Bundler.setup(:default, :test)
@ -91,7 +91,7 @@ RSpec.describe "Bundler.setup" do
it "handles multiple non-additive invocations" do
ruby <<-RUBY, :raise_on_error => false
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup(:default, :test)
Bundler.setup(:default)
require 'rack'
@ -122,7 +122,7 @@ RSpec.describe "Bundler.setup" do
ENV["RUBYLIB"] = "rubylib_dir"
ruby <<-RUBY
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup
puts $LOAD_PATH
RUBY
@ -143,6 +143,10 @@ RSpec.describe "Bundler.setup" do
gem "rails"
G
# We require an absolute path because relying on the $LOAD_PATH behaves
# inconsistently depending on whether we're in a ruby-core setup (and
# bundler's lib is in RUBYLIB) or not.
ruby <<-RUBY
require '#{lib_dir}/bundler'
Bundler.setup
@ -171,6 +175,10 @@ RSpec.describe "Bundler.setup" do
gem "terranova"
G
# We require an absolute path because relying on the $LOAD_PATH behaves
# inconsistently depending on whether we're in a ruby-core setup (and
# bundler's lib is in RUBYLIB) or not.
ruby <<-RUBY
require '#{lib_dir}/bundler/setup'
puts $LOAD_PATH
@ -192,8 +200,10 @@ RSpec.describe "Bundler.setup" do
gem "rack"
G
entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler" : "bundler"
ruby <<-R
require '#{lib_dir}/bundler'
require '#{entrypoint}'
begin
Bundler.setup
@ -213,7 +223,7 @@ RSpec.describe "Bundler.setup" do
G
ruby <<-R, :raise_on_error => false
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup
R
@ -236,7 +246,7 @@ RSpec.describe "Bundler.setup" do
G
ruby <<-R, :raise_on_error => false
require '#{lib_dir}/bundler'
require 'bundler'
Bundler.setup
R
@ -289,7 +299,7 @@ RSpec.describe "Bundler.setup" do
ENV["BUNDLE_GEMFILE"] = "Gemfile"
ruby <<-R
require '#{lib_dir}/bundler'
require 'bundler'
begin
Bundler.setup
@ -444,7 +454,7 @@ RSpec.describe "Bundler.setup" do
break_git!
ruby <<-R
require '#{lib_dir}/bundler'
require 'bundler'
begin
Bundler.setup
@ -464,8 +474,10 @@ RSpec.describe "Bundler.setup" do
break_git!
entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler" : "bundler"
ruby <<-R
require "#{lib_dir}/bundler"
require "#{entrypoint}"
begin
Bundler.setup
@ -798,7 +810,7 @@ end
# Don't build extensions.
s.class.send(:define_method, :build_extensions) { nil }
require '#{lib_dir}/bundler'
require 'bundler'
gem '#{gem_name}'
puts $LOAD_PATH.count {|path| path =~ /#{gem_name}/} >= 2
@ -1056,7 +1068,7 @@ end
bundle "install"
ruby <<-RUBY
require '#{lib_dir}/bundler'
require 'bundler'
bundler_module = class << Bundler; self; end
bundler_module.send(:remove_method, :require)
def Bundler.require(path)
@ -1104,6 +1116,8 @@ end
end
before do
bundle "config set --local path.system true"
install_gemfile <<-G
source "#{file_uri_for(gem_repo1)}"
gem "rack"
@ -1112,8 +1126,9 @@ end
context "is not present" do
it "does not change the lock" do
entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup"
lockfile lock_with(nil)
ruby "require '#{lib_dir}/bundler/setup'"
ruby "require '#{entrypoint}'"
lockfile_should_be lock_with(nil)
end
end
@ -1121,7 +1136,7 @@ end
context "is newer" do
it "does not change the lock or warn" do
lockfile lock_with(Bundler::VERSION.succ)
ruby "require '#{lib_dir}/bundler/setup'"
ruby "require 'bundler/setup'"
expect(out).to be_empty
expect(err).to be_empty
lockfile_should_be lock_with(Bundler::VERSION.succ)
@ -1130,8 +1145,10 @@ end
context "is older" do
it "does not change the lock" do
entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup"
system_gems "bundler-1.10.1"
lockfile lock_with("1.10.1")
ruby "require '#{lib_dir}/bundler/setup'"
ruby "require '#{entrypoint}'"
lockfile_should_be lock_with("1.10.1")
end
end
@ -1178,14 +1195,14 @@ end
context "is not present" do
it "does not change the lock" do
expect { ruby "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile }
expect { ruby "require 'bundler/setup'" }.not_to change { lockfile }
end
end
context "is newer" do
let(:ruby_version) { "5.5.5" }
it "does not change the lock or warn" do
expect { ruby "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile }
expect { ruby "require 'bundler/setup'" }.not_to change { lockfile }
expect(out).to be_empty
expect(err).to be_empty
end
@ -1194,7 +1211,7 @@ end
context "is older" do
let(:ruby_version) { "1.0.0" }
it "does not change the lock" do
expect { ruby "require '#{lib_dir}/bundler/setup'" }.not_to change { lockfile }
expect { ruby "require 'bundler/setup'" }.not_to change { lockfile }
end
end
end
@ -1202,8 +1219,9 @@ end
describe "with gemified standard libraries" do
it "does not load Psych" do
gemfile ""
entrypoint = mis_activates_prerelease_default_bundler? ? "#{lib_dir}/bundler/setup" : "bundler/setup"
ruby <<-RUBY
require '#{lib_dir}/bundler/setup'
require '#{entrypoint}'
puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined"
require 'psych'
puts Psych::VERSION
@ -1216,7 +1234,7 @@ end
it "does not load openssl" do
install_gemfile ""
ruby <<-RUBY
require "#{lib_dir}/bundler/setup"
require "bundler/setup"
puts defined?(OpenSSL) || "undefined"
require "openssl"
puts defined?(OpenSSL) || "undefined"
@ -1274,7 +1292,7 @@ end
it "activates no gems with -rbundler/setup" do
install_gemfile ""
ruby code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -r#{lib_dir}/bundler/setup" }
ruby code, :env => { "RUBYOPT" => activation_warning_hack_rubyopt + " -rbundler/setup" }
expect(out).to eq("{}")
end
@ -1327,7 +1345,7 @@ end
if File.exist?(ext_folder.join("#{require_name}.rb"))
{ :exclude_from_load_path => ext_folder.to_s }
else
lib_folder = source_root.join("lib")
lib_folder = source_lib_dir
if File.exist?(lib_folder.join("#{require_name}.rb"))
{ :exclude_from_load_path => lib_folder.to_s }
else
@ -1383,7 +1401,7 @@ end
G
ruby <<-RUBY
require "#{lib_dir}/bundler/setup"
require "bundler/setup"
Object.new.gem "rack"
puts Gem.loaded_specs["rack"].full_name
RUBY
@ -1398,7 +1416,7 @@ end
G
ruby <<-RUBY, :raise_on_error => false
require "#{lib_dir}/bundler/setup"
require "bundler/setup"
Object.new.gem "rack"
puts "FAIL"
RUBY
@ -1414,7 +1432,7 @@ end
G
ruby <<-RUBY, :raise_on_error => false
require "#{lib_dir}/bundler/setup"
require "bundler/setup"
Object.new.require "rack"
puts "FAIL"
RUBY
@ -1429,4 +1447,9 @@ end
expect(last_command.stdboth).to eq("true")
end
end
# Tested rubygems does not include https://github.com/rubygems/rubygems/pull/2728 and will not always end up activating the current bundler
def mis_activates_prerelease_default_bundler?
Gem.rubygems_version < Gem::Version.new("3.1.a")
end
end

View file

@ -547,9 +547,11 @@ module Spec
class GitBuilder < LibBuilder
def _build(options)
default_branch = options[:default_branch] || "master"
path = options[:path] || _default_path
source = options[:source] || "git@#{path}"
super(options.merge(:path => path, :source => source))
@context.git("config --global init.defaultBranch #{default_branch}", path)
@context.git("init", path)
@context.git("add *", path)
@context.git("config user.email lol@wut.com", path)