diff options
-rwxr-xr-x | exe/bundle_ruby | 60 | ||||
-rw-r--r-- | lib/bundler/fetcher/downloader.rb | 2 | ||||
-rw-r--r-- | spec/bundler/fetcher/downloader_spec.rb | 12 | ||||
-rw-r--r-- | spec/other/bundle_ruby_spec.rb | 155 | ||||
-rw-r--r-- | spec/other/major_deprecation_spec.rb | 8 | ||||
-rw-r--r-- | spec/support/helpers.rb | 5 |
6 files changed, 12 insertions, 230 deletions
diff --git a/exe/bundle_ruby b/exe/bundle_ruby deleted file mode 100755 index df6f8cc8a1..0000000000 --- a/exe/bundle_ruby +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require "bundler/shared_helpers" - -Bundler::SharedHelpers.major_deprecation(2, "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`") - -Signal.trap("INT") { exit 1 } - -require "bundler/errors" -require "bundler/ruby_version" -require "bundler/ruby_dsl" - -module Bundler - class Dsl - include RubyDsl - - attr_accessor :ruby_version - - def initialize - @ruby_version = nil - end - - def eval_gemfile(gemfile, contents = nil) - contents ||= File.open(gemfile, "rb", &:read) - instance_eval(contents, gemfile.to_s, 1) - rescue SyntaxError => e - bt = e.message.split("\n")[1..-1] - raise GemfileError, ["Gemfile syntax error:", *bt].join("\n") - rescue ScriptError, RegexpError, NameError, ArgumentError => e - e.backtrace[0] = "#{e.backtrace[0]}: #{e.message} (#{e.class})" - STDERR.puts e.backtrace.join("\n ") - raise GemfileError, "There was an error in your Gemfile," \ - " and Bundler cannot continue." - end - - def source(source, options = {}) - end - - def gem(name, *args) - end - - def group(*args) - end - end -end - -dsl = Bundler::Dsl.new -begin - dsl.eval_gemfile(Bundler::SharedHelpers.default_gemfile) - ruby_version = dsl.ruby_version - if ruby_version - puts ruby_version - else - puts "No ruby version specified" - end -rescue Bundler::GemfileError => e - puts e.message - exit(-1) -end diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb index e0e0cbf1c9..87ad4140fd 100644 --- a/lib/bundler/fetcher/downloader.rb +++ b/lib/bundler/fetcher/downloader.rb @@ -37,7 +37,7 @@ module Bundler when Net::HTTPUnauthorized raise AuthenticationRequiredError, uri.host when Net::HTTPNotFound - raise FallbackError, "Net::HTTPNotFound" + raise FallbackError, "Net::HTTPNotFound: #{URICredentialsFilter.credential_filtered_uri(uri)}" else raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}" end diff --git a/spec/bundler/fetcher/downloader_spec.rb b/spec/bundler/fetcher/downloader_spec.rb index c9b4fa662a..07b507266b 100644 --- a/spec/bundler/fetcher/downloader_spec.rb +++ b/spec/bundler/fetcher/downloader_spec.rb @@ -88,7 +88,17 @@ RSpec.describe Bundler::Fetcher::Downloader do let(:http_response) { Net::HTTPNotFound.new("1.1", 404, "Not Found") } it "should raise a Bundler::Fetcher::FallbackError with Net::HTTPNotFound" do - expect { subject.fetch(uri, options, counter) }.to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound") + expect { subject.fetch(uri, options, counter) }. + to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound: http://www.uri-to-fetch.com/api/v2/endpoint") + end + + context "when the there are credentials provided in the request" do + let(:uri) { URI("http://username:password@www.uri-to-fetch.com/api/v2/endpoint") } + + it "should raise a Bundler::Fetcher::FallbackError that doesn't contain the password" do + expect { subject.fetch(uri, options, counter) }. + to raise_error(Bundler::Fetcher::FallbackError, "Net::HTTPNotFound: http://username@www.uri-to-fetch.com/api/v2/endpoint") + end end end diff --git a/spec/other/bundle_ruby_spec.rb b/spec/other/bundle_ruby_spec.rb deleted file mode 100644 index a7da9cbec9..0000000000 --- a/spec/other/bundle_ruby_spec.rb +++ /dev/null @@ -1,155 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe "bundle_ruby", :bundler => "< 2" do - context "without patchlevel" do - it "returns the ruby version" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3", :engine => 'ruby', :engine_version => '1.9.3' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.9.3") - end - - it "engine defaults to MRI" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3" - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.9.3") - end - - it "handles jruby" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'jruby', :engine_version => '1.6.5' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.8.7 (jruby 1.6.5)") - end - - it "handles rbx" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'rbx', :engine_version => '1.2.4' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.8.7 (rbx 1.2.4)") - end - - it "handles truffleruby", :rubygems => ">= 2.1.0" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "2.5.1", :engine => 'truffleruby', :engine_version => '1.0.0-rc6' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 2.5.1 (truffleruby 1.0.0-rc6)") - end - - it "raises an error if engine is used but engine version is not" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'rbx' - - gem "foo" - G - - bundle_ruby - expect(exitstatus).not_to eq(0) if exitstatus - - bundle_ruby - expect(out).to include("Please define :engine_version") - end - - it "raises an error if engine_version is used but engine is not" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine_version => '1.2.4' - - gem "foo" - G - - bundle_ruby - expect(exitstatus).not_to eq(0) if exitstatus - - bundle_ruby - expect(out).to include("Please define :engine") - end - - it "raises an error if engine version doesn't match ruby version for MRI" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.8.7", :engine => 'ruby', :engine_version => '1.2.4' - - gem "foo" - G - - bundle_ruby - expect(exitstatus).not_to eq(0) if exitstatus - - bundle_ruby - expect(out).to include("ruby_version must match the :engine_version for MRI") - end - - it "should print if no ruby version is specified" do - gemfile <<-G - source "file://#{gem_repo1}" - - gem "foo" - G - - bundle_ruby - - expect(out).to include("No ruby version specified") - end - end - - context "when using patchlevel" do - it "returns the ruby version" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3", :patchlevel => '429', :engine => 'ruby', :engine_version => '1.9.3' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.9.3p429") - end - - it "handles an engine" do - gemfile <<-G - source "file://#{gem_repo1}" - ruby "1.9.3", :patchlevel => '392', :engine => 'jruby', :engine_version => '1.7.4' - - gem "foo" - G - - bundle_ruby - - expect(out).to include("ruby 1.9.3p392 (jruby 1.7.4)") - end - end -end diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb index ce2735ba94..e8de574c79 100644 --- a/spec/other/major_deprecation_spec.rb +++ b/spec/other/major_deprecation_spec.rb @@ -31,14 +31,6 @@ RSpec.describe "major deprecations", :bundler => "< 2" do bundle! "install" end - describe "bundle_ruby" do - it "prints a deprecation" do - bundle_ruby - warnings.gsub! "\nruby #{RUBY_VERSION}", "" - expect(warnings).to have_major_deprecation "the bundle_ruby executable has been removed in favor of `bundle platform --ruby`" - end - end - describe "Bundler" do describe ".clean_env" do it "is deprecated in favor of .unbundled_env" do diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index 9126256f8e..af6b1c556a 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -174,11 +174,6 @@ module Spec bundle(cmd, options) end - def bundle_ruby(options = {}) - options["bundle_bin"] = bindir.join("bundle_ruby") - bundle("", options) - end - def ruby(ruby, options = {}) env = (options.delete(:env) || {}).map {|k, v| "#{k}='#{v}' " }.join ruby = ruby.gsub(/["`\$]/) {|m| "\\#{m}" } |