diff options
author | The Bundler Bot <bot@bundler.io> | 2017-12-12 00:04:20 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-12-12 00:04:20 +0000 |
commit | ce967788bf62e030556825d160e7aa448c80b311 (patch) | |
tree | 93b9d29fcd995bbb0eeca14ce5d53f98b2d305b2 | |
parent | 9fad58f2228df40527c9edec06b0f7ca696264b8 (diff) | |
parent | 058cb07f5ba4704eb55974780855fd33daa86bb4 (diff) | |
download | bundler-ce967788bf62e030556825d160e7aa448c80b311.tar.gz |
Auto merge of #6212 - hsbt:prepare-v1.16.1, r=hsbt
Prepare to release v1.16.1
I picked merge commits targeted v1.16.1 from https://github.com/bundler/bundler/milestone/56 .
26 files changed, 187 insertions, 34 deletions
diff --git a/bundler.gemspec b/bundler.gemspec index dade77f32e..6cd542c95a 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -48,6 +48,8 @@ Gem::Specification.new do |s| s.files += Dir.glob("man/**/*") # Include the CHANGELOG.md, LICENSE.md, README.md manually s.files += %w[CHANGELOG.md LICENSE.md README.md] + # include the gemspec itself because warbler breaks w/o it + s.files += %w[bundler.gemspec] s.bindir = "exe" s.executables = %w[bundle bundler] diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index a18d929791..885578e819 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -83,7 +83,7 @@ module Bundler config[:test] = test_framework config[:test_framework_version] = TEST_FRAMEWORK_VERSIONS[test_framework] - templates.merge!(".travis.yml.tt" => ".travis.yml") + templates.merge!("travis.yml.tt" => ".travis.yml") case test_framework when "rspec" diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index 5de11e84e4..3890ea307a 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -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 diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index f93ed76226..ad16389dae 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -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 diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index ddc1d702e0..bfc6b91576 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -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 diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 6f4157364f..3cf22a50f1 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -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 diff --git a/lib/bundler/templates/.document b/lib/bundler/templates/.document new file mode 100644 index 0000000000..fb66f13c33 --- /dev/null +++ b/lib/bundler/templates/.document @@ -0,0 +1 @@ +# Ignore all files in this directory diff --git a/lib/bundler/templates/Executable b/lib/bundler/templates/Executable index 9289debc26..414a75898d 100755 --- a/lib/bundler/templates/Executable +++ b/lib/bundler/templates/Executable @@ -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" diff --git a/lib/bundler/templates/newgem/.travis.yml.tt b/lib/bundler/templates/newgem/travis.yml.tt index fe0761cc23..fe0761cc23 100644 --- a/lib/bundler/templates/newgem/.travis.yml.tt +++ b/lib/bundler/templates/newgem/travis.yml.tt diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb index d78ad50b61..24ee03ec3c 100644 --- a/spec/commands/binstubs_spec.rb +++ b/spec/commands/binstubs_spec.rb @@ -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 diff --git a/spec/commands/exec_spec.rb b/spec/commands/exec_spec.rb index c32b760a1e..ae31487937 100644 --- a/spec/commands/exec_spec.rb +++ b/spec/commands/exec_spec.rb @@ -61,8 +61,6 @@ RSpec.describe "bundle exec" do it "handles --keep-file-descriptors" do require "tempfile" - bundle_bin = File.expand_path("../../../exe/bundle", __FILE__) - command = Tempfile.new("io-test") command.sync = true command.write <<-G @@ -71,7 +69,7 @@ RSpec.describe "bundle exec" do else require 'tempfile' io = Tempfile.new("io-test-fd") - args = %W[#{Gem.ruby} -I#{lib} #{bundle_bin} exec --keep-file-descriptors #{Gem.ruby} #{command.path} \#{io.to_i}] + args = %W[#{Gem.ruby} -I#{lib} #{bindir.join("bundle")} exec --keep-file-descriptors #{Gem.ruby} #{command.path} \#{io.to_i}] args << { io.to_i => io } if RUBY_VERSION >= "2.0" exec(*args) end @@ -474,7 +472,7 @@ RSpec.describe "bundle exec" do Bundler.rubygems.extend(Monkey) G bundle "install --deployment" - bundle "exec ruby -e '`../../exe/bundler -v`; puts $?.success?'" + bundle "exec ruby -e '`#{bindir.join("bundler")} -v`; puts $?.success?'" expect(out).to match("true") end end diff --git a/spec/commands/newgem_spec.rb b/spec/commands/newgem_spec.rb index 259c73a903..494599abf1 100644 --- a/spec/commands/newgem_spec.rb +++ b/spec/commands/newgem_spec.rb @@ -40,7 +40,7 @@ RSpec.describe "bundle gem" do user = bundleuser EOF @git_config_location = ENV["GIT_CONFIG"] - path = "#{File.expand_path("../../tmp", File.dirname(__FILE__))}/test_git_config.txt" + path = "#{File.expand_path(tmp, File.dirname(__FILE__))}/test_git_config.txt" File.open(path, "w") {|f| f.write(git_config_content) } ENV["GIT_CONFIG"] = path end @@ -170,11 +170,10 @@ RSpec.describe "bundle gem" do # This spec cannot have `git` available in the test env before do - bundle_bin = File.expand_path("../../../exe/bundle", __FILE__) load_paths = [lib, spec] load_path_str = "-I#{load_paths.join(File::PATH_SEPARATOR)}" - sys_exec "PATH=\"\" #{Gem.ruby} #{load_path_str} #{bundle_bin} gem #{gem_name}" + sys_exec "PATH=\"\" #{Gem.ruby} #{load_path_str} #{bindir.join("bundle")} gem #{gem_name}" end it "creates the gem without the need for git" do diff --git a/spec/commands/show_spec.rb b/spec/commands/show_spec.rb index d91ac275d1..0bdf6a4a9c 100644 --- a/spec/commands/show_spec.rb +++ b/spec/commands/show_spec.rb @@ -41,7 +41,7 @@ RSpec.describe "bundle show", :bundler => "< 2" do it "prints the path to the running bundler" do bundle "show bundler" - expect(out).to eq(File.expand_path("../../../", __FILE__)) + expect(out).to eq(root.to_s) end it "complains if gem not in bundle" do diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index a8283cf593..a2842f0998 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -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 diff --git a/spec/realworld/double_check_spec.rb b/spec/realworld/double_check_spec.rb new file mode 100644 index 0000000000..0aa58b3de3 --- /dev/null +++ b/spec/realworld/double_check_spec.rb @@ -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 diff --git a/spec/resolver/basic_spec.rb b/spec/resolver/basic_spec.rb index d5658824ba..623d092644 100644 --- a/spec/resolver/basic_spec.rb +++ b/spec/resolver/basic_spec.rb @@ -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" diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index 388ee049d0..dcee234e15 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -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 diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb index dcaba3ab9d..18ca246199 100644 --- a/spec/runtime/inline_spec.rb +++ b/spec/runtime/inline_spec.rb @@ -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 diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb index 78eebaff79..b160e5b409 100644 --- a/spec/runtime/with_clean_env_spec.rb +++ b/spec/runtime/with_clean_env_spec.rb @@ -79,7 +79,7 @@ RSpec.describe "Bundler.with_env helpers" do it "should clean up RUBYLIB" do code = "print Bundler.clean_env['RUBYLIB']" - ENV["RUBYLIB"] = File.expand_path("../../../lib", __FILE__) + File::PATH_SEPARATOR + "/foo" + ENV["RUBYLIB"] = root.join("lib").to_s + File::PATH_SEPARATOR + "/foo" result = bundle("exec '#{Gem.ruby}' -e #{code.inspect}") expect(result).to eq("/foo") end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1b3be98442..a0925bb679 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,7 +11,7 @@ require "digest" require File.expand_path("../support/path.rb", __FILE__) begin - spec = Gem::Specification.load("bundler.gemspec") + spec = Gem::Specification.load(Spec::Path.gemspec.to_s) rspec = spec.dependencies.find {|d| d.name == "rspec" } gem "rspec", rspec.requirement.to_s require "rspec" @@ -47,7 +47,7 @@ $debug = false Spec::Manpages.setup Spec::Rubygems.setup FileUtils.rm_rf(Spec::Path.gem_repo1) -ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.root}/spec/support/hax.rb" +ENV["RUBYOPT"] = "#{ENV["RUBYOPT"]} -r#{Spec::Path.spec_dir}/support/hax.rb" ENV["BUNDLE_SPEC_RUN"] = "true" # Don't wrap output in tests diff --git a/spec/support/artifice/endpoint.rb b/spec/support/artifice/endpoint.rb index 94f2b5cbc9..9afecff8e6 100644 --- a/spec/support/artifice/endpoint.rb +++ b/spec/support/artifice/endpoint.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require File.expand_path("../../path.rb", __FILE__) -require File.expand_path("../../../../lib/bundler/deprecate", __FILE__) +require Spec::Path.root.join("lib/bundler/deprecate") include Spec::Path $LOAD_PATH.unshift(*Dir[Spec::Path.base_system_gems.join("gems/{artifice,rack,tilt,sinatra}-*/lib")].map(&:to_s)) diff --git a/spec/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/request b/spec/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/request new file mode 100644 index 0000000000..ed63e334fa --- /dev/null +++ b/spec/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/request @@ -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
\ No newline at end of file diff --git a/spec/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/response b/spec/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/response Binary files differnew file mode 100644 index 0000000000..4e2fc2b8cd --- /dev/null +++ b/spec/support/artifice/vcr_cassettes/realworld/rubygems.org/gems/rack-2.0.1.gem/GET/response diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 4e81f321f0..6201631011 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -88,11 +88,11 @@ module Spec end def lib - File.expand_path("../../../lib", __FILE__) + root.join("lib") end def spec - File.expand_path("../../../spec", __FILE__) + spec_dir.to_s end def bundle(cmd, options = {}) @@ -102,7 +102,7 @@ module Spec no_color = options.delete("no-color") { cmd.to_s !~ /\A(e|ex|exe|exec|conf|confi|config)(\s|\z)/ } options["no-color"] = true if no_color - bundle_bin = options.delete("bundle_bin") || File.expand_path("../../../exe/bundle", __FILE__) + bundle_bin = options.delete("bundle_bin") || bindir.join("bundle") if system_bundler = options.delete(:system_bundler) bundle_bin = "-S bundle" @@ -171,12 +171,12 @@ module Spec end def bundler(cmd, options = {}) - options["bundle_bin"] = File.expand_path("../../../exe/bundler", __FILE__) + options["bundle_bin"] = bindir.join("bundler") bundle(cmd, options) end def bundle_ruby(options = {}) - options["bundle_bin"] = File.expand_path("../../../exe/bundle_ruby", __FILE__) + options["bundle_bin"] = bindir.join("bundle_ruby") bundle("", options) end @@ -300,7 +300,7 @@ module Spec gem_repo = options.fetch(:gem_repo) { gem_repo1 } gems.each do |g| path = if g == :bundler - Dir.chdir(root) { gem_command! :build, "#{root}/bundler.gemspec" } + Dir.chdir(root) { gem_command! :build, gemspec.to_s } bundler_path = root + "bundler-#{Bundler::VERSION}.gem" elsif g.to_s =~ %r{\A/.*\.gem\z} g diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb index 05605195b1..c56d6145a7 100644 --- a/spec/support/indexes.rb +++ b/spec/support/indexes.rb @@ -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 diff --git a/spec/support/path.rb b/spec/support/path.rb index 54fc03c850..b24ac16d5b 100644 --- a/spec/support/path.rb +++ b/spec/support/path.rb @@ -8,6 +8,18 @@ module Spec @root ||= Pathname.new(File.expand_path("../../..", __FILE__)) end + def gemspec + @gemspec ||= Pathname.new(File.expand_path(root.join("bundler.gemspec"), __FILE__)) + end + + def bindir + @bindir ||= Pathname.new(File.expand_path(root.join("exe"), __FILE__)) + end + + def spec_dir + @spec_dir ||= Pathname.new(File.expand_path(root.join("spec"), __FILE__)) + end + def tmp(*path) root.join("tmp", *path) end @@ -83,7 +95,7 @@ module Spec end def bundler_path - Pathname.new(File.expand_path("../../../lib", __FILE__)) + Pathname.new(File.expand_path(root.join("lib"), __FILE__)) end def global_plugin_gem(*args) |