mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merge 1-16-stable branch of bundler.
It's rc version for bundler-1.16.1. I'm going to update it version after official release from bundler team. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f1c3395099
commit
a1a20cfaa2
25 changed files with 226 additions and 58 deletions
|
@ -1,7 +1,12 @@
|
|||
# coding: utf-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
require File.expand_path("../bundler/version", __FILE__)
|
||||
version = File.expand_path("../lib/bundler/version", __FILE__)
|
||||
if File.file?(version)
|
||||
require version
|
||||
else # for Ruby core repository
|
||||
require File.expand_path("../bundler/version", __FILE__)
|
||||
end
|
||||
require "shellwords"
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
|
@ -163,6 +168,7 @@ Gem::Specification.new do |s|
|
|||
lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem
|
||||
lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem
|
||||
lib/bundler/stub_specification.rb
|
||||
lib/bundler/templates/.document
|
||||
lib/bundler/templates/Executable
|
||||
lib/bundler/templates/Executable.bundler
|
||||
lib/bundler/templates/Executable.standalone
|
||||
|
@ -333,6 +339,7 @@ Gem::Specification.new do |s|
|
|||
CHANGELOG.md
|
||||
LICENSE.md
|
||||
README.md
|
||||
bundler.gemspec
|
||||
]
|
||||
|
||||
s.bindir = "exe"
|
||||
|
|
|
@ -36,11 +36,7 @@ module Bundler
|
|||
private
|
||||
|
||||
def gemfile
|
||||
@gemfile ||= begin
|
||||
Bundler.default_gemfile
|
||||
rescue GemfileNotFound
|
||||
Bundler.feature_flag.init_gems_rb? ? "gems.rb" : "Gemfile"
|
||||
end
|
||||
@gemfile ||= Bundler.feature_flag.init_gems_rb? ? "gems.rb" : "Gemfile"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,9 @@ module Bundler
|
|||
|
||||
if locked_gems = Bundler.definition.locked_gems
|
||||
gems.each do |name|
|
||||
locked_version = locked_gems.specs.find {|s| s.name == name }.version
|
||||
locked_version = locked_gems.specs.find {|s| s.name == name }
|
||||
locked_version &&= locked_version.version
|
||||
next unless locked_version
|
||||
new_version = Bundler.definition.specs[name].first
|
||||
new_version &&= new_version.version
|
||||
if !new_version
|
||||
|
|
|
@ -295,7 +295,7 @@ module Bundler
|
|||
end
|
||||
|
||||
sources.all_sources.each do |source|
|
||||
source.double_check_for(unmet_dependency_names, :override_dupes)
|
||||
source.double_check_for(unmet_dependency_names)
|
||||
end
|
||||
|
||||
break if idxcount == idx.size
|
||||
|
|
|
@ -245,7 +245,8 @@ module Bundler
|
|||
if all <= 1
|
||||
all - 1_000_000
|
||||
else
|
||||
search = search_for(dependency).size
|
||||
search = search_for(dependency)
|
||||
search = @prerelease_specified[dependency.name] ? search.count : search.count {|s| !s.version.prerelease? }
|
||||
search - all
|
||||
end
|
||||
end
|
||||
|
|
|
@ -252,10 +252,8 @@ module Bundler
|
|||
end
|
||||
end
|
||||
|
||||
def double_check_for(unmet_dependency_names, override_dupes = false, index = specs)
|
||||
def double_check_for(unmet_dependency_names)
|
||||
return unless @allow_remote
|
||||
raise ArgumentError, "missing index" unless index
|
||||
|
||||
return unless api_fetchers.any?
|
||||
|
||||
unmet_dependency_names = unmet_dependency_names.call
|
||||
|
@ -270,7 +268,7 @@ module Bundler
|
|||
|
||||
Bundler.ui.debug "Double checking for #{unmet_dependency_names || "all specs (due to the size of the request)"} in #{self}"
|
||||
|
||||
fetch_names(api_fetchers, unmet_dependency_names, index, override_dupes)
|
||||
fetch_names(api_fetchers, unmet_dependency_names, specs, false)
|
||||
end
|
||||
|
||||
def dependency_names_to_double_check
|
||||
|
|
|
@ -8,13 +8,21 @@
|
|||
# this file is here to facilitate running it.
|
||||
#
|
||||
|
||||
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
||||
load(bundle_binstub) if File.file?(bundle_binstub)
|
||||
|
||||
require "pathname"
|
||||
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../<%= relative_gemfile_path %>",
|
||||
Pathname.new(__FILE__).realpath)
|
||||
|
||||
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
||||
|
||||
if File.file?(bundle_binstub)
|
||||
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
||||
load(bundle_binstub)
|
||||
else
|
||||
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
||||
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
||||
end
|
||||
end
|
||||
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ module Bundler
|
|||
# We're doing this because we might write tests that deal
|
||||
# with other versions of bundler and we are unsure how to
|
||||
# handle this better.
|
||||
VERSION = "1.16.0" unless defined?(::Bundler::VERSION)
|
||||
VERSION = "1.16.1.pre1" unless defined?(::Bundler::VERSION)
|
||||
|
||||
def self.overwrite_loaded_gem_version
|
||||
begin
|
||||
|
|
|
@ -95,11 +95,15 @@ RSpec.describe Bundler::Fetcher do
|
|||
|
||||
context "when bunder ssl ssl configuration is set" do
|
||||
before do
|
||||
cert = File.join(Spec::Path.tmpdir, "cert")
|
||||
File.open(cert, "w") {|f| f.write "PEM" }
|
||||
allow(Bundler.settings).to receive(:[]).and_return(nil)
|
||||
allow(Bundler.settings).to receive(:[]).with(:ssl_client_cert).and_return("/cert")
|
||||
expect(File).to receive(:read).with("/cert").and_return("")
|
||||
expect(OpenSSL::X509::Certificate).to receive(:new).and_return("cert")
|
||||
expect(OpenSSL::PKey::RSA).to receive(:new).and_return("key")
|
||||
allow(Bundler.settings).to receive(:[]).with(:ssl_client_cert).and_return(cert)
|
||||
expect(OpenSSL::X509::Certificate).to receive(:new).with("PEM").and_return("cert")
|
||||
expect(OpenSSL::PKey::RSA).to receive(:new).with("PEM").and_return("key")
|
||||
end
|
||||
after do
|
||||
FileUtils.rm File.join(Spec::Path.tmpdir, "cert")
|
||||
end
|
||||
it "use bundler configuration" do
|
||||
expect(fetcher.send(:connection).cert).to eq("cert")
|
||||
|
|
|
@ -50,6 +50,25 @@ RSpec.describe "bundle binstubs <gem>" do
|
|||
expect(out).to include("`bundle binstubs` needs at least one gem to run.")
|
||||
end
|
||||
|
||||
context "when generating bundle binstub outside bundler" do
|
||||
it "should abort" do
|
||||
install_gemfile <<-G
|
||||
source "file://#{gem_repo1}"
|
||||
gem "rack"
|
||||
G
|
||||
|
||||
bundle "binstubs rack"
|
||||
|
||||
File.open("bin/bundle", "wb") do |file|
|
||||
file.print "OMG"
|
||||
end
|
||||
|
||||
sys_exec "bin/rackup"
|
||||
|
||||
expect(last_command.stderr).to include("was not generated by Bundler")
|
||||
end
|
||||
end
|
||||
|
||||
context "the bundle binstub" do
|
||||
before do
|
||||
if system_bundler_version == :bundler
|
||||
|
|
|
@ -13,9 +13,9 @@ RSpec.describe "bundle init" do
|
|||
expect(bundled_app("gems.rb")).to be_file
|
||||
end
|
||||
|
||||
context "when a Gemfile already exists" do
|
||||
context "when a Gemfile already exists", :bundler => "< 2" do
|
||||
before do
|
||||
gemfile <<-G
|
||||
create_file "Gemfile", <<-G
|
||||
gem "rails"
|
||||
G
|
||||
end
|
||||
|
@ -30,14 +30,14 @@ RSpec.describe "bundle init" do
|
|||
end
|
||||
end
|
||||
|
||||
context "when a gems.rb already exists" do
|
||||
context "when gems.rb already exists", :bundler => ">= 2" do
|
||||
before do
|
||||
create_file "gems.rb", <<-G
|
||||
create_file("gems.rb", <<-G)
|
||||
gem "rails"
|
||||
G
|
||||
end
|
||||
|
||||
it "does not change existing gem.rb files" do
|
||||
it "does not change existing Gemfiles" do
|
||||
expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
|
||||
end
|
||||
|
||||
|
@ -47,6 +47,40 @@ RSpec.describe "bundle init" do
|
|||
end
|
||||
end
|
||||
|
||||
context "when a Gemfile exists in a parent directory", :bundler => "< 2" do
|
||||
let(:subdir) { "child_dir" }
|
||||
|
||||
it "lets users generate a Gemfile in a child directory" do
|
||||
bundle! :init
|
||||
|
||||
FileUtils.mkdir bundled_app(subdir)
|
||||
|
||||
Dir.chdir bundled_app(subdir) do
|
||||
bundle! :init
|
||||
end
|
||||
|
||||
expect(out).to include("Writing new Gemfile")
|
||||
expect(bundled_app("#{subdir}/Gemfile")).to be_file
|
||||
end
|
||||
end
|
||||
|
||||
context "when a gems.rb file exists in a parent directory", :bundler => ">= 2" do
|
||||
let(:subdir) { "child_dir" }
|
||||
|
||||
it "lets users generate a Gemfile in a child directory" do
|
||||
bundle! :init
|
||||
|
||||
FileUtils.mkdir bundled_app(subdir)
|
||||
|
||||
Dir.chdir bundled_app(subdir) do
|
||||
bundle! :init
|
||||
end
|
||||
|
||||
expect(out).to include("Writing new gems.rb")
|
||||
expect(bundled_app("#{subdir}/gems.rb")).to be_file
|
||||
end
|
||||
end
|
||||
|
||||
context "given --gemspec option", :bundler => "< 2" do
|
||||
let(:spec_file) { tmp.join("test.gemspec") }
|
||||
|
||||
|
@ -94,28 +128,6 @@ RSpec.describe "bundle init" do
|
|||
context "when init_gems_rb setting is enabled" do
|
||||
before { bundle "config init_gems_rb true" }
|
||||
|
||||
it "generates a gems.rb file" do
|
||||
bundle :init
|
||||
expect(bundled_app("gems.rb")).to exist
|
||||
end
|
||||
|
||||
context "when gems.rb already exists" do
|
||||
before do
|
||||
create_file("gems.rb", <<-G)
|
||||
gem "rails"
|
||||
G
|
||||
end
|
||||
|
||||
it "does not change existing Gemfiles" do
|
||||
expect { bundle :init }.not_to change { File.read(bundled_app("gems.rb")) }
|
||||
end
|
||||
|
||||
it "notifies the user that an existing gems.rb already exists" do
|
||||
bundle :init
|
||||
expect(out).to include("gems.rb already exists")
|
||||
end
|
||||
end
|
||||
|
||||
context "given --gemspec option", :bundler => "< 2" do
|
||||
let(:spec_file) { tmp.join("test.gemspec") }
|
||||
|
||||
|
|
|
@ -195,6 +195,23 @@ RSpec.describe "bundle update" do
|
|||
expect(the_bundle).not_to include_gems "foo 2.0"
|
||||
end
|
||||
end
|
||||
|
||||
context "when bundler itself is a transitive dependency" do
|
||||
it "executes without error" do
|
||||
install_gemfile <<-G
|
||||
source "file://#{gem_repo1}"
|
||||
gem "activesupport", :group => :development
|
||||
gem "rack"
|
||||
G
|
||||
update_repo2 do
|
||||
build_gem "activesupport", "3.0"
|
||||
end
|
||||
bundle "update --group development"
|
||||
expect(the_bundle).to include_gems "activesupport 2.3.5"
|
||||
expect(the_bundle).to include_gems "bundler #{Bundler::VERSION}"
|
||||
expect(the_bundle).not_to include_gems "rack 1.2"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "in a frozen bundle" do
|
||||
|
|
|
@ -97,7 +97,7 @@ RSpec.describe "real source plugins" do
|
|||
|
||||
lockfile_should_be <<-G
|
||||
GEM
|
||||
remote: file:#{gem_repo2}/
|
||||
remote: file://localhost#{gem_repo2}/
|
||||
specs:
|
||||
|
||||
PLUGIN SOURCE
|
||||
|
@ -392,7 +392,7 @@ RSpec.describe "real source plugins" do
|
|||
|
||||
lockfile_should_be <<-G
|
||||
GEM
|
||||
remote: file:#{gem_repo2}/
|
||||
remote: file://localhost#{gem_repo2}/
|
||||
specs:
|
||||
|
||||
PLUGIN SOURCE
|
||||
|
|
42
spec/bundler/realworld/double_check_spec.rb
Normal file
42
spec/bundler/realworld/double_check_spec.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "double checking sources", :realworld => true do
|
||||
if RUBY_VERSION >= "2.2" # rails 5.x and rack 2.x only supports >= Ruby 2.2.
|
||||
it "finds already-installed gems" do
|
||||
create_file("rails.gemspec", <<-RUBY)
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "rails"
|
||||
s.version = "5.1.4"
|
||||
s.summary = ""
|
||||
s.description = ""
|
||||
s.author = ""
|
||||
s.add_dependency "actionpack", "5.1.4"
|
||||
end
|
||||
RUBY
|
||||
|
||||
create_file("actionpack.gemspec", <<-RUBY)
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "actionpack"
|
||||
s.version = "5.1.4"
|
||||
s.summary = ""
|
||||
s.description = ""
|
||||
s.author = ""
|
||||
s.add_dependency "rack", "~> 2.0.0"
|
||||
end
|
||||
RUBY
|
||||
|
||||
cmd = <<-RUBY
|
||||
require "bundler"
|
||||
require #{File.expand_path("../../support/artifice/vcr.rb", __FILE__).dump}
|
||||
require "bundler/inline"
|
||||
gemfile(true) do
|
||||
source "https://rubygems.org"
|
||||
gem "rails", path: "."
|
||||
end
|
||||
RUBY
|
||||
|
||||
ruby! cmd
|
||||
ruby! cmd
|
||||
end
|
||||
end
|
||||
end
|
|
@ -42,6 +42,13 @@ RSpec.describe "Resolving" do
|
|||
should_resolve_as %w[a-1.0.0 b-2.0.0 c-1.0.0 d-1.0.0]
|
||||
end
|
||||
|
||||
it "prefers non-prerelease resolutions in sort order" do
|
||||
@index = optional_prereleases_index
|
||||
dep "a"
|
||||
dep "b"
|
||||
should_resolve_as %w[a-1.0.0 b-1.5.0]
|
||||
end
|
||||
|
||||
it "resolves a index with root level conflict on child" do
|
||||
@index = a_index_with_root_conflict_on_child
|
||||
dep "i18n", "~> 0.4"
|
||||
|
|
|
@ -158,4 +158,33 @@ RSpec.describe "Running bin/* commands" do
|
|||
|
||||
expect(bundled_app("bin/rackup").read).to_not eq("OMG")
|
||||
end
|
||||
|
||||
it "use BUNDLE_GEMFILE gemfile for binstub" do
|
||||
# context with bin/bunlder w/ default Gemfile
|
||||
bundle! "binstubs bundler"
|
||||
|
||||
# generate other Gemfile with executable gem
|
||||
build_repo2 do
|
||||
build_gem("bindir") {|s| s.executables = "foo" }
|
||||
end
|
||||
|
||||
create_file("OtherGemfile", <<-G)
|
||||
source "file://#{gem_repo2}"
|
||||
gem 'bindir'
|
||||
G
|
||||
|
||||
# generate binstub for executable from non default Gemfile (other then bin/bundler version)
|
||||
ENV["BUNDLE_GEMFILE"] = "OtherGemfile"
|
||||
bundle "install"
|
||||
bundle! "binstubs bindir"
|
||||
|
||||
# remove user settings
|
||||
ENV["BUNDLE_GEMFILE"] = nil
|
||||
|
||||
# run binstub for non default Gemfile
|
||||
gembin "foo"
|
||||
|
||||
expect(exitstatus).to eq(0) if exitstatus
|
||||
expect(out).to eq("1.0")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,10 +43,6 @@ RSpec.describe "bundler/inline#gemfile" do
|
|||
build_lib "eight", "1.0.0" do |s|
|
||||
s.write "lib/eight.rb", "puts 'eight'"
|
||||
end
|
||||
|
||||
build_lib "four", "1.0.0" do |s|
|
||||
s.write "lib/four.rb", "puts 'four'"
|
||||
end
|
||||
end
|
||||
|
||||
it "requires the gems" do
|
||||
|
|
|
@ -80,7 +80,7 @@ RSpec.describe "Bundler.with_env helpers" do
|
|||
it "should clean up RUBYLIB", :ruby_repo do
|
||||
code = "print Bundler.clean_env['RUBYLIB']"
|
||||
ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo"
|
||||
result = bundle("exec ruby -e #{code.inspect}")
|
||||
result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}")
|
||||
expect(result).to eq("/foo")
|
||||
end
|
||||
|
||||
|
|
|
@ -99,6 +99,8 @@ RSpec.configure do |config|
|
|||
|
||||
original_wd = Dir.pwd
|
||||
original_env = ENV.to_hash.delete_if {|k, _v| k.start_with?(Bundler::EnvironmentPreserver::BUNDLER_PREFIX) }
|
||||
original_default_specs = Dir[File.join(Gem.default_dir, "specifications", "default", "bundler*")]
|
||||
original_site_ruby_dirs = $LOAD_PATH.select {|path| path =~ /site_ruby/ }.map {|path| File.join(path, "bundler*") }.compact.map {|path| Dir[path] }.flatten
|
||||
|
||||
config.expect_with :rspec do |c|
|
||||
c.syntax = :expect
|
||||
|
@ -113,6 +115,11 @@ RSpec.configure do |config|
|
|||
|
||||
config.before :all do
|
||||
build_repo1
|
||||
(original_default_specs + original_site_ruby_dirs).each {|s| FileUtils.mv(s, s + ".org") }
|
||||
end
|
||||
|
||||
config.after :all do
|
||||
(original_default_specs + original_site_ruby_dirs).each {|s| FileUtils.mv(s + ".org", s) if File.exist?(s + ".org") }
|
||||
end
|
||||
|
||||
config.before :each do
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
> GET /gems/rack-2.0.1.gem
|
||||
> accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
||||
> accept: */*
|
||||
> user-agent: Ruby
|
||||
> connection: keep-alive
|
||||
> keep-alive: 30
|
||||
> host: rubygems.org
|
Binary file not shown.
|
@ -391,7 +391,7 @@ module Spec
|
|||
index
|
||||
end
|
||||
|
||||
def build_spec(name, version, platform = nil, &block)
|
||||
def build_spec(name, version = "0.0.1", platform = nil, &block)
|
||||
Array(version).map do |v|
|
||||
Gem::Specification.new do |s|
|
||||
s.name = name
|
||||
|
|
|
@ -401,5 +401,20 @@ module Spec
|
|||
gem("d", %w[1.0.0 2.0.0])
|
||||
end
|
||||
end
|
||||
|
||||
def optional_prereleases_index
|
||||
build_index do
|
||||
gem("a", %w[1.0.0])
|
||||
|
||||
gem("a", "2.0.0") do
|
||||
dep "b", ">= 2.0.0.pre"
|
||||
end
|
||||
|
||||
gem("b", %w[0.9.0 1.5.0 2.0.0.pre])
|
||||
|
||||
# --- Pre-release support
|
||||
gem "rubygems\0", ["1.3.2"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,7 +54,8 @@ module Spec
|
|||
|
||||
def self.install_gems(gems)
|
||||
reqs, no_reqs = gems.partition {|_, req| !req.nil? && !req.split(" ").empty? }
|
||||
reqs = reqs.sort_by {|name, _| name == "rack" ? 0 : 1 } # TODO: remove when we drop ruby 1.8.7 support
|
||||
# TODO: remove when we drop ruby 1.8.7-2.2.2 support
|
||||
reqs = reqs.sort_by {|name, _| name == "rack" ? 0 : 1 }.sort_by {|name, _| name =~ /rack/ ? 0 : 1 }
|
||||
no_reqs.map!(&:first)
|
||||
reqs.map! {|name, req| "'#{name}:#{req}'" }
|
||||
deps = reqs.concat(no_reqs).join(" ")
|
||||
|
|
|
@ -349,7 +349,7 @@ RSpec.describe "bundle update" do
|
|||
|
||||
lockfile_should_be <<-G
|
||||
GEM
|
||||
remote: file:#{gem_repo2}/
|
||||
remote: file://localhost#{gem_repo2}/
|
||||
specs:
|
||||
rack (1.0.0)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue