[前][次][番号順一覧][スレッド一覧]

ruby-changes:49019

From: hsbt <ko1@a...>
Date: Tue, 12 Dec 2017 15:15:50 +0900 (JST)
Subject: [ruby-changes:49019] hsbt:r61134 (trunk): Merge 1-16-stable branch of bundler.

hsbt	2017-12-12 15:15:44 +0900 (Tue, 12 Dec 2017)

  New Revision: 61134

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61134

  Log:
    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.

  Added directories:
    trunk/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/
    trunk/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/
  Added files:
    trunk/spec/bundler/realworld/double_check_spec.rb
    trunk/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/request
    trunk/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/response
  Modified files:
    trunk/lib/bundler/cli/init.rb
    trunk/lib/bundler/cli/update.rb
    trunk/lib/bundler/definition.rb
    trunk/lib/bundler/resolver.rb
    trunk/lib/bundler/source/rubygems.rb
    trunk/lib/bundler/templates/Executable
    trunk/lib/bundler/version.rb
    trunk/lib/bundler.gemspec
    trunk/spec/bundler/bundler/fetcher_spec.rb
    trunk/spec/bundler/commands/binstubs_spec.rb
    trunk/spec/bundler/commands/init_spec.rb
    trunk/spec/bundler/commands/update_spec.rb
    trunk/spec/bundler/plugins/source/example_spec.rb
    trunk/spec/bundler/resolver/basic_spec.rb
    trunk/spec/bundler/runtime/executable_spec.rb
    trunk/spec/bundler/runtime/inline_spec.rb
    trunk/spec/bundler/runtime/with_clean_env_spec.rb
    trunk/spec/bundler/spec_helper.rb
    trunk/spec/bundler/support/builders.rb
    trunk/spec/bundler/support/indexes.rb
    trunk/spec/bundler/support/rubygems_ext.rb
    trunk/spec/bundler/update/git_spec.rb
Index: lib/bundler.gemspec
===================================================================
--- lib/bundler.gemspec	(revision 61133)
+++ lib/bundler.gemspec	(revision 61134)
@@ -1,7 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler.gemspec#L1
 # 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| https://github.com/ruby/ruby/blob/trunk/lib/bundler.gemspec#L168
     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| https://github.com/ruby/ruby/blob/trunk/lib/bundler.gemspec#L339
     CHANGELOG.md
     LICENSE.md
     README.md
+    bundler.gemspec
   ]
 
   s.bindir        = "exe"
Index: lib/bundler/definition.rb
===================================================================
--- lib/bundler/definition.rb	(revision 61133)
+++ lib/bundler/definition.rb	(revision 61134)
@@ -295,7 +295,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L295
         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
Index: lib/bundler/resolver.rb
===================================================================
--- lib/bundler/resolver.rb	(revision 61133)
+++ lib/bundler/resolver.rb	(revision 61134)
@@ -245,7 +245,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/resolver.rb#L245
           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
Index: lib/bundler/cli/init.rb
===================================================================
--- lib/bundler/cli/init.rb	(revision 61133)
+++ lib/bundler/cli/init.rb	(revision 61134)
@@ -36,11 +36,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/init.rb#L36
   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
Index: lib/bundler/cli/update.rb
===================================================================
--- lib/bundler/cli/update.rb	(revision 61133)
+++ lib/bundler/cli/update.rb	(revision 61134)
@@ -68,7 +68,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/cli/update.rb#L68
 
       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
Index: lib/bundler/source/rubygems.rb
===================================================================
--- lib/bundler/source/rubygems.rb	(revision 61133)
+++ lib/bundler/source/rubygems.rb	(revision 61134)
@@ -252,10 +252,8 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L252
         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 https://github.com/ruby/ruby/blob/trunk/lib/bundler/source/rubygems.rb#L268
 
         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
Index: lib/bundler/templates/Executable
===================================================================
--- lib/bundler/templates/Executable	(revision 61133)
+++ lib/bundler/templates/Executable	(revision 61134)
@@ -8,13 +8,21 @@ https://github.com/ruby/ruby/blob/trunk/lib/bundler/templates/Executable#L8
 # 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"
 
Index: lib/bundler/version.rb
===================================================================
--- lib/bundler/version.rb	(revision 61133)
+++ lib/bundler/version.rb	(revision 61134)
@@ -7,7 +7,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/version.rb#L7
   # 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
Index: spec/bundler/bundler/fetcher_spec.rb
===================================================================
--- spec/bundler/bundler/fetcher_spec.rb	(revision 61133)
+++ spec/bundler/bundler/fetcher_spec.rb	(revision 61134)
@@ -95,11 +95,15 @@ RSpec.describe Bundler::Fetcher do https://github.com/ruby/ruby/blob/trunk/spec/bundler/bundler/fetcher_spec.rb#L95
 
     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")
Index: spec/bundler/realworld/double_check_spec.rb
===================================================================
--- spec/bundler/realworld/double_check_spec.rb	(nonexistent)
+++ spec/bundler/realworld/double_check_spec.rb	(revision 61134)
@@ -0,0 +1,42 @@ https://github.com/ruby/ruby/blob/trunk/spec/bundler/realworld/double_check_spec.rb#L1
+# 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
Index: spec/bundler/spec_helper.rb
===================================================================
--- spec/bundler/spec_helper.rb	(revision 61133)
+++ spec/bundler/spec_helper.rb	(revision 61134)
@@ -99,6 +99,8 @@ RSpec.configure do |config| https://github.com/ruby/ruby/blob/trunk/spec/bundler/spec_helper.rb#L99
 
   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| https://github.com/ruby/ruby/blob/trunk/spec/bundler/spec_helper.rb#L115
 
   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
Index: spec/bundler/support/builders.rb
===================================================================
--- spec/bundler/support/builders.rb	(revision 61133)
+++ spec/bundler/support/builders.rb	(revision 61134)
@@ -391,7 +391,7 @@ module Spec https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/builders.rb#L391
       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
Index: spec/bundler/support/rubygems_ext.rb
===================================================================
--- spec/bundler/support/rubygems_ext.rb	(revision 61133)
+++ spec/bundler/support/rubygems_ext.rb	(revision 61134)
@@ -54,7 +54,8 @@ module Spec https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/rubygems_ext.rb#L54
 
     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(" ")
Index: spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/request
===================================================================
--- spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/request	(nonexistent)
+++ spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/request	(revision 61134)
@@ -0,0 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/request#L1
+> 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
\ No newline at end of file
Index: spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/response
===================================================================
Binary files spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/response	(nonexistent) and spec/bundler/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/response	(revision 61134) differ
Index: spec/bundler/support/indexes.rb
===================================================================
--- spec/bundler/support/indexes.rb	(revision 61133)
+++ spec/bundler/support/indexes.rb	(revision 61134)
@@ -401,5 +401,20 @@ module Spec https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/indexes.rb#L401
         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
Index: spec/bundler/commands/init_spec.rb
===================================================================
--- spec/bundler/commands/init_spec.rb	(revision 61133)
+++ spec/bundler/commands/init_spec.rb	(revision 61134)
@@ -13,9 +13,9 @@ RSpec.describe "bundle init" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/init_spec.rb#L13
     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 https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/init_spec.rb#L30
     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 https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/init_spec.rb#L47
     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 https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/init_spec.rb#L128
   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") }
 
Index: spec/bundler/commands/update_spec.rb
===================================================================
--- spec/bundler/commands/update_spec.rb	(revision 61133)
+++ spec/bundler/commands/update_spec.rb	(revision 61134)
@@ -195,6 +195,23 @@ RSpec.describe "bundle update" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/update_spec.rb#L195
         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
Index: spec/bundler/commands/binstubs_spec.rb
===================================================================
--- spec/bundler/commands/binstubs_spec.rb	(revision 61133)
+++ spec/bundler/commands/binstubs_spec.rb	(revision 61134)
@@ -50,6 +50,25 @@ RSpec.describe "bundle binstubs <gem>" d https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/binstubs_spec.rb#L50
       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
Index: spec/bundler/plugins/source/example_spec.rb
===================================================================
--- spec/bundler/plugins/source/example_spec.rb	(revision 61133)
+++ spec/bundler/plugins/source/example_spec.rb	(revision 61134)
@@ -97,7 +97,7 @@ RSpec.describe "real source plugins" do https://github.com/ruby/ (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]