diff options
58 files changed, 278 insertions, 207 deletions
diff --git a/.travis.yml b/.travis.yml index 8581b190dc..65ca9bb54b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,9 +31,9 @@ addons: secure: "TrzIv116JLGUxm6PAUskCYrv8KTDguncKROVwbnjVPKTGDAgoDderd8JUdDEXrKoZ9qGLD2TPYKExt9/QDl71E+qHdWnVqWv4HKCUk2P9z/VLKzHuggOUBkCXiJUhjywUieCJhI3N92bfq2EjSBbu2/OFHqWOjLQ+QCooTEBjv8=" rvm: - - 2.6.2 + - 2.6.3 - 2.5.5 - - 2.4.5 + - 2.4.6 stages: - linting @@ -51,7 +51,7 @@ env: jobs: include: - - rvm: 2.6.2 + - rvm: 2.6.3 script: rake rubocop stage: linting # Ruby 2.3 also tested in 2.x mode @@ -66,7 +66,7 @@ jobs: env: RGV=v2.7.9 stage: test # Ruby 2.4, Rubygems 2.6 - - rvm: 2.4.5 + - rvm: 2.4.6 env: RGV=v2.6.14 stage: test # Ruby 2.3, Rubygems 2.5 @@ -199,72 +199,73 @@ task :rubocop do end namespace :man do - ronn_dep = development_dependencies.find do |dep| - dep.name == "ronn" - end + if RUBY_ENGINE == "jruby" + task(:build) {} + else + ronn_dep = development_dependencies.find do |dep| + dep.name == "ronn" + end - ronn_requirement = ronn_dep.requirement.to_s + ronn_requirement = ronn_dep.requirement.to_s - begin - gem "ronn", ronn_requirement + begin + gem "ronn", ronn_requirement - require "ronn" - rescue LoadError - task(:require) { abort "We couln't activate ronn (#{ronn_requirement}). Try `gem install ronn:'#{ronn_requirement}'` to be able to release!" } - task(:build) { abort "We couln't activate ronn (#{ronn_requirement}). Try `gem install ronn:'#{ronn_requirement}'` to be able to build the help pages" } - else - directory "man" + require "ronn" + rescue LoadError + task(:build) { abort "We couln't activate ronn (#{ronn_requirement}). Try `gem install ronn:'#{ronn_requirement}'` to be able to build the help pages" } + else + directory "man" - index = [] - sources = Dir["man/*.ronn"].map {|f| File.basename(f, ".ronn") } - sources.map do |basename| - ronn = "man/#{basename}.ronn" - manual_section = ".1" unless basename =~ /\.(\d+)\Z/ - roff = "man/#{basename}#{manual_section}" + index = [] + sources = Dir["man/*.ronn"].map {|f| File.basename(f, ".ronn") } + sources.map do |basename| + ronn = "man/#{basename}.ronn" + manual_section = ".1" unless basename =~ /\.(\d+)\Z/ + roff = "man/#{basename}#{manual_section}" - index << [ronn, File.basename(roff)] + index << [ronn, File.basename(roff)] - file roff => ["man", ronn] do - sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}" - end - - file "#{roff}.txt" => roff do - sh "groff -Wall -mtty-char -mandoc -Tascii #{roff} | col -b > #{roff}.txt" - end + file roff => ["man", ronn] do + sh "#{Gem.ruby} -S ronn --roff --pipe #{ronn} > #{roff}" + end - task :build_all_pages => "#{roff}.txt" - end + file "#{roff}.txt" => roff do + sh "groff -Wall -mtty-char -mandoc -Tascii #{roff} | col -b > #{roff}.txt" + end - file "index.txt" do - index.map! do |(ronn, roff)| - [File.read(ronn).split(" ").first, roff] + task :build_all_pages => "#{roff}.txt" end - index = index.sort_by(&:first) - justification = index.map {|(n, _f)| n.length }.max + 4 - File.open("man/index.txt", "w") do |f| - index.each do |name, filename| - f << name.ljust(justification) << filename << "\n" + + file "index.txt" do + index.map! do |(ronn, roff)| + [File.read(ronn).split(" ").first, roff] + end + index = index.sort_by(&:first) + justification = index.map {|(n, _f)| n.length }.max + 4 + File.open("man/index.txt", "w") do |f| + index.each do |name, filename| + f << name.ljust(justification) << filename << "\n" + end end end - end - task :build_all_pages => "index.txt" + task :build_all_pages => "index.txt" - task :clean do - leftovers = Dir["man/*"].reject do |f| - File.extname(f) == ".ronn" + task :clean do + leftovers = Dir["man/*"].reject do |f| + File.extname(f) == ".ronn" + end + rm leftovers if leftovers.any? end - rm leftovers if leftovers.any? - end - desc "Build the man pages" - task :build => ["man:clean", "man:build_all_pages"] + desc "Build the man pages" + task :build => ["man:clean", "man:build_all_pages"] - desc "Remove all built man pages" - task :clobber do - rm_rf "lib/bundler/man" + desc "Remove all built man pages" + task :clobber do + rm_rf "lib/bundler/man" + end end - - task(:require) {} end end diff --git a/bin/with_rubygems b/bin/with_rubygems index 72edc1c928..96299669be 100755 --- a/bin/with_rubygems +++ b/bin/with_rubygems @@ -4,7 +4,7 @@ require "pathname" def run(*cmd) - return if system(*cmd) + return if system(*cmd, :out => IO::NULL) raise "Running `#{cmd.join(" ")}` failed" end @@ -20,8 +20,6 @@ unless rubygems_path.directory? run("git remote update") version = "v#{version}" if version =~ /\A\d/ run("git", "checkout", version, "--quiet") - hash = `git rev-parse HEAD`.chomp - puts "Checked out rubygems '#{version}' at #{hash}" end end diff --git a/lib/bundler.rb b/lib/bundler.rb index f792a3bc98..0c24a21d7a 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true -require "bundler/compatibility_guard" +require_relative "bundler/compatibility_guard" -require "bundler/vendored_fileutils" +require_relative "bundler/vendored_fileutils" require "pathname" require "rbconfig" -require "bundler/errors" -require "bundler/environment_preserver" -require "bundler/plugin" -require "bundler/rubygems_ext" -require "bundler/rubygems_integration" -require "bundler/version" -require "bundler/constants" -require "bundler/current_ruby" -require "bundler/build_metadata" +require_relative "bundler/errors" +require_relative "bundler/environment_preserver" +require_relative "bundler/plugin" +require_relative "bundler/rubygems_ext" +require_relative "bundler/rubygems_integration" +require_relative "bundler/version" +require_relative "bundler/constants" +require_relative "bundler/current_ruby" +require_relative "bundler/build_metadata" module Bundler environment_preserver = EnvironmentPreserver.new(ENV, EnvironmentPreserver::BUNDLER_KEYS) diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb index 1b7145b72b..573df95043 100644 --- a/lib/bundler/capistrano.rb +++ b/lib/bundler/capistrano.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/shared_helpers" +require_relative "shared_helpers" Bundler::SharedHelpers.major_deprecation 2, "The Bundler task for Capistrano. Please use http://github.com/capistrano/bundler" @@ -8,7 +8,7 @@ Bundler::SharedHelpers.major_deprecation 2, # # Add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and # Bundler will be activated after each new deployment. -require "bundler/deployment" +require_relative "deployment" require "capistrano/version" if defined?(Capistrano::Version) && Gem::Version.new(Capistrano::Version).release >= Gem::Version.new("3.0") diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 4e3735847e..dd733a22ed 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true -require "bundler" -require "bundler/vendored_thor" +require_relative "vendored_thor" module Bundler class CLI < Thor - require "bundler/cli/common" + require_relative "cli/common" package_name "Bundler" @@ -139,7 +138,7 @@ module Bundler D method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile" def init - require "bundler/cli/init" + require_relative "cli/init" Init.new(options.dup).run end @@ -157,7 +156,7 @@ module Bundler "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}" map "c" => "check" def check - require "bundler/cli/check" + require_relative "cli/check" Check.new(options).run end @@ -168,7 +167,7 @@ module Bundler method_option "install", :type => :boolean, :banner => "Runs 'bundle install' after removing the gems from the Gemfile" def remove(*gems) - require "bundler/cli/remove" + require_relative "cli/remove" Remove.new(gems, options).run end @@ -230,7 +229,7 @@ module Bundler remembered_flag_deprecation(option) end - require "bundler/cli/install" + require_relative "cli/install" Bundler.settings.temporary(:no_install => false) do Install.new(options.dup).run end @@ -276,7 +275,7 @@ module Bundler "Update everything." def update(*gems) SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force") - require "bundler/cli/update" + require_relative "cli/update" Bundler.settings.temporary(:no_install => false) do Update.new(options, gems).run end @@ -312,7 +311,7 @@ module Bundler Bundler::SharedHelpers.major_deprecation(2, "use `bundle #{new_argv}` instead of `bundle #{old_argv}`") end end - require "bundler/cli/show" + require_relative "cli/show" Show.new(options, gem_name).run end end @@ -323,7 +322,7 @@ module Bundler method_option "without-group", :type => :string, :banner => "print all gems except from a group" method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle" def list - require "bundler/cli/list" + require_relative "cli/list" List.new(options).run end @@ -332,7 +331,7 @@ module Bundler desc "info GEM [OPTIONS]", "Show information for the given gem" method_option "path", :type => :boolean, :banner => "Print full path to gem" def info(gem_name) - require "bundler/cli/info" + require_relative "cli/info" Info.new(options, gem_name).run end @@ -353,7 +352,7 @@ module Bundler method_option "all", :type => :boolean, :banner => "Install binstubs for all gems" def binstubs(*gems) - require "bundler/cli/binstubs" + require_relative "cli/binstubs" Binstubs.new(options, gems).run end @@ -364,12 +363,14 @@ module Bundler method_option "version", :aliases => "-v", :type => :string method_option "group", :aliases => "-g", :type => :string method_option "source", :aliases => "-s", :type => :string + method_option "git", :type => :string + method_option "branch", :type => :string method_option "skip-install", :type => :boolean, :banner => "Adds gem to the Gemfile but does not install it" method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem" method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem" def add(*gems) - require "bundler/cli/add" + require_relative "cli/add" Add.new(options.dup, gems).run end @@ -405,7 +406,7 @@ module Bundler method_option "only-explicit", :type => :boolean, :banner => "Only list gems specified in your Gemfile, not their dependencies" def outdated(*gems) - require "bundler/cli/outdated" + require_relative "cli/outdated" Outdated.new(options, gems).run end @@ -420,7 +421,7 @@ module Bundler method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one" method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache." def cache - require "bundler/cli/cache" + require_relative "cli/cache" Cache.new(options).run end end @@ -448,7 +449,7 @@ module Bundler bundle without having to download any additional gems. D def package - require "bundler/cli/package" + require_relative "cli/package" Package.new(options).run end map %w[pack] => :package @@ -463,7 +464,7 @@ module Bundler D map "e" => "exec" def exec(*args) - require "bundler/cli/exec" + require_relative "cli/exec" Exec.new(options, args).run end @@ -479,19 +480,19 @@ module Bundler will show the current value, as well as any superceded values and where they were specified. D - require "bundler/cli/config" + require_relative "cli/config" subcommand "config", Config desc "open GEM", "Opens the source directory of the given bundled gem" def open(name) - require "bundler/cli/open" + require_relative "cli/open" Open.new(options, name).run end unless Bundler.feature_flag.bundler_3_mode? desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded" def console(group = nil) - require "bundler/cli/console" + require_relative "cli/console" Console.new(options, group).run end end @@ -539,7 +540,7 @@ module Bundler method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group." def viz SharedHelpers.major_deprecation 2, "The `viz` command has been moved to the `bundle-viz` gem, see https://github.com/bundler/bundler-viz" - require "bundler/cli/viz" + require_relative "cli/viz" Viz.new(options.dup).run end end @@ -563,7 +564,7 @@ module Bundler def gem_command.run(instance, args = []) arity = 1 # name - require "bundler/cli/gem" + require_relative "cli/gem" cmd_args = args + [instance] cmd_args.unshift(instance.options) @@ -591,7 +592,7 @@ module Bundler method_option "force", :type => :boolean, :default => false, :banner => "Forces clean even if --path is not set" def clean - require "bundler/cli/clean" + require_relative "cli/clean" Clean.new(options.dup).run end @@ -599,7 +600,7 @@ module Bundler method_option "ruby", :type => :boolean, :default => false, :banner => "only display ruby related platform information" def platform - require "bundler/cli/platform" + require_relative "cli/platform" Platform.new(options).run end @@ -610,7 +611,7 @@ module Bundler "Install gem into a bundler group" def inject(name, version) SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command" - require "bundler/cli/inject" + require_relative "cli/inject" Inject.new(options.dup, name, version).run end @@ -642,7 +643,7 @@ module Bundler method_option "conservative", :type => :boolean, :banner => "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated" def lock - require "bundler/cli/lock" + require_relative "cli/lock" Lock.new(options).run end @@ -662,13 +663,13 @@ module Bundler method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors." def doctor - require "bundler/cli/doctor" + require_relative "cli/doctor" Doctor.new(options).run end desc "issue", "Learn how to report an issue in Bundler" def issue - require "bundler/cli/issue" + require_relative "cli/issue" Issue.new.run end @@ -679,12 +680,12 @@ module Bundler checkout --force`. D def pristine(*gems) - require "bundler/cli/pristine" + require_relative "cli/pristine" Pristine.new(gems).run end if Bundler.feature_flag.plugins? - require "bundler/cli/plugin" + require_relative "cli/plugin" desc "plugin", "Manage the bundler plugins" subcommand "plugin", Plugin end diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index 9ea52baa6b..5ec541f722 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -59,7 +59,7 @@ module Bundler end def self.gem_not_found_message(missing_gem_name, alternatives) - require "bundler/similarity_detector" + require_relative "../similarity_detector" message = "Could not find gem '#{missing_gem_name}'." alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a } suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name) diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb index 6d038937c0..1b3913a300 100644 --- a/lib/bundler/cli/doctor.rb +++ b/lib/bundler/cli/doctor.rb @@ -56,7 +56,7 @@ module Bundler end def check! - require "bundler/cli/check" + require_relative "check" Bundler::CLI::Check.new({}).run end diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb index c29d632307..6fdd55d106 100644 --- a/lib/bundler/cli/exec.rb +++ b/lib/bundler/cli/exec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/current_ruby" +require_relative "../current_ruby" module Bundler class CLI::Exec @@ -69,7 +69,7 @@ module Bundler Process.setproctitle(process_title(file, args)) if Process.respond_to?(:setproctitle) ui = Bundler.ui Bundler.ui = nil - require "bundler/setup" + require_relative "../setup" TRAPPED_SIGNALS.each {|s| trap(s, "DEFAULT") } Kernel.load(file) rescue SystemExit, SignalException diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 03edc7fbd2..cf0c71d766 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -80,7 +80,7 @@ module Bundler warn_ambiguous_gems if CLI::Common.clean_after_install? - require "bundler/cli/clean" + require_relative "clean" Bundler::CLI::Clean.new(options).run end rescue GemNotFound, VersionConflict => e diff --git a/lib/bundler/cli/issue.rb b/lib/bundler/cli/issue.rb index bba1619340..054ce76315 100644 --- a/lib/bundler/cli/issue.rb +++ b/lib/bundler/cli/issue.rb @@ -33,7 +33,7 @@ module Bundler end def doctor - require "bundler/cli/doctor" + require_relative "doctor" Bundler::CLI::Doctor.new({}).run end end diff --git a/lib/bundler/cli/package.rb b/lib/bundler/cli/package.rb index cd01ce422e..120a3fdcf3 100644 --- a/lib/bundler/cli/package.rb +++ b/lib/bundler/cli/package.rb @@ -25,7 +25,7 @@ module Bundler private def install - require "bundler/cli/install" + require_relative "install" options = self.options.dup if Bundler.settings[:cache_all_platforms] options["local"] = false diff --git a/lib/bundler/cli/plugin.rb b/lib/bundler/cli/plugin.rb index b5dd5b6d4b..1155c4ec9b 100644 --- a/lib/bundler/cli/plugin.rb +++ b/lib/bundler/cli/plugin.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/vendored_thor" +require_relative "../vendored_thor" module Bundler class CLI::Plugin < Thor desc "install PLUGINS", "Install the plugin from the source" diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb index b088853768..13d71bb50e 100644 --- a/lib/bundler/cli/update.rb +++ b/lib/bundler/cli/update.rb @@ -62,7 +62,7 @@ module Bundler Bundler.load.cache if Bundler.app_cache.exist? if CLI::Common.clean_after_install? - require "bundler/cli/clean" + require_relative "clean" Bundler::CLI::Clean.new(options).run end diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb index 2f713041c8..a5120dbba4 100644 --- a/lib/bundler/compact_index_client.rb +++ b/lib/bundler/compact_index_client.rb @@ -13,8 +13,8 @@ module Bundler class Error < StandardError; end - require "bundler/compact_index_client/cache" - require "bundler/compact_index_client/updater" + require_relative "compact_index_client/cache" + require_relative "compact_index_client/updater" attr_reader :directory diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb index d77285072c..40232019bc 100644 --- a/lib/bundler/compact_index_client/updater.rb +++ b/lib/bundler/compact_index_client/updater.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/vendored_fileutils" +require_relative "../vendored_fileutils" require "stringio" require "zlib" diff --git a/lib/bundler/compatibility_guard.rb b/lib/bundler/compatibility_guard.rb index 958116ce55..eaff1a10d4 100644 --- a/lib/bundler/compatibility_guard.rb +++ b/lib/bundler/compatibility_guard.rb @@ -1,6 +1,6 @@ # frozen_string_literal: false -require "bundler/version" +require_relative "version" if Bundler::VERSION.split(".").first.to_i >= 2 if Gem::Version.new(Object::RUBY_VERSION.dup) < Gem::Version.new("2.3") diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index f9daae067c..506b0620d2 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/lockfile_parser" +require_relative "lockfile_parser" require "set" module Bundler @@ -385,7 +385,7 @@ module Bundler end def to_lock - require "bundler/lockfile_generator" + require_relative "lockfile_generator" LockfileGenerator.generate(self) end diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index 8840ad6a9c..0d588bc892 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true require "rubygems/dependency" -require "bundler/shared_helpers" -require "bundler/rubygems_ext" +require_relative "shared_helpers" +require_relative "rubygems_ext" module Bundler class Dependency < Gem::Dependency attr_reader :autorequire - attr_reader :groups, :platforms, :gemfile + attr_reader :groups, :platforms, :gemfile, :git, :branch PLATFORM_MAP = { :ruby => Gem::Platform::RUBY, @@ -84,6 +84,8 @@ module Bundler @autorequire = nil @groups = Array(options["group"] || :default).map(&:to_sym) @source = options["source"] + @git = options["git"] + @branch = options["branch"] @platforms = Array(options["platforms"]) @env = options["env"] @should_include = options.fetch("should_include", true) diff --git a/lib/bundler/deployment.rb b/lib/bundler/deployment.rb index 291e158ca0..b432ae6ae1 100644 --- a/lib/bundler/deployment.rb +++ b/lib/bundler/deployment.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/shared_helpers" +require_relative "shared_helpers" Bundler::SharedHelpers.major_deprecation 2, "Bundler no longer integrates with " \ "Capistrano, but Capistrano provides its own integration with " \ "Bundler via the capistrano-bundler gem. Use it instead." diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 7424a5c8a4..d3ead2a1ff 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "bundler/dependency" -require "bundler/ruby_dsl" +require_relative "dependency" +require_relative "ruby_dsl" module Bundler class Dsl diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb index 3216eb2776..a08db08aa0 100644 --- a/lib/bundler/env.rb +++ b/lib/bundler/env.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "bundler/rubygems_integration" -require "bundler/source/git/git_proxy" +require_relative "rubygems_integration" +require_relative "source/git/git_proxy" module Bundler class Env diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 8397f7b72b..7ec41d62c0 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/vendored_persistent" +require_relative "vendored_persistent" require "cgi" require "securerandom" require "zlib" diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb index a117af72fa..1efd3e03af 100644 --- a/lib/bundler/fetcher/compact_index.rb +++ b/lib/bundler/fetcher/compact_index.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "bundler/fetcher/base" -require "bundler/worker" +require_relative "base" +require_relative "../worker" module Bundler autoload :CompactIndexClient, "bundler/compact_index_client" diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb index 1430d1ebeb..c52c32fb5b 100644 --- a/lib/bundler/fetcher/dependency.rb +++ b/lib/bundler/fetcher/dependency.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/fetcher/base" +require_relative "base" require "cgi" module Bundler diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb index 1a8064624d..e7baf63873 100644 --- a/lib/bundler/fetcher/index.rb +++ b/lib/bundler/fetcher/index.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/fetcher/base" +require_relative "base" require "rubygems/remote_fetcher" module Bundler diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index dd9b847f10..45faf02020 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "cgi" -require "bundler/vendored_thor" +require_relative "vendored_thor" module Bundler module FriendlyErrors diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index e9ee03b8a2..33f1d51592 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "bundler/vendored_thor" unless defined?(Thor) -require "bundler" +require_relative "vendored_thor" unless defined?(Thor) +require_relative "../bundler" require "shellwords" module Bundler diff --git a/lib/bundler/gem_tasks.rb b/lib/bundler/gem_tasks.rb index f736517bd7..bc725d3602 100644 --- a/lib/bundler/gem_tasks.rb +++ b/lib/bundler/gem_tasks.rb @@ -3,5 +3,5 @@ require "rake/clean" CLOBBER.include "pkg" -require "bundler/gem_helper" +require_relative "gem_helper" Bundler::GemHelper.install_tasks diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb index e67469f2dd..2cdda578e2 100644 --- a/lib/bundler/injector.rb +++ b/lib/bundler/injector.rb @@ -111,8 +111,10 @@ module Bundler end source = ", :source => \"#{d.source}\"" unless d.source.nil? + git = ", :git => \"#{d.git}\"" unless d.git.nil? + branch = ", :branch => \"#{d.branch}\"" unless d.branch.nil? - %(gem #{name}#{requirement}#{group}#{source}) + %(gem #{name}#{requirement}#{group}#{source}#{git}#{branch}) end.join("\n") end diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb index 93355c9460..317bf892ab 100644 --- a/lib/bundler/inline.rb +++ b/lib/bundler/inline.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/compatibility_guard" +require_relative "compatibility_guard" # Allows for declaring a Gemfile inline in a ruby script, optionally installing # any gems that aren't already installed on the user's system. @@ -32,7 +32,7 @@ require "bundler/compatibility_guard" # puts Pod::VERSION # => "0.34.4" # def gemfile(install = false, options = {}, &gemfile) - require "bundler" + require_relative "../bundler" opts = options.dup ui = opts.delete(:ui) { Bundler::UI::Shell.new } @@ -49,26 +49,28 @@ def gemfile(install = false, options = {}, &gemfile) builder = Bundler::Dsl.new builder.instance_eval(&gemfile) - definition = builder.to_definition(nil, true) - def definition.lock(*); end - definition.validate_runtime! + Bundler.settings.temporary(:frozen => false) do + definition = builder.to_definition(nil, true) + def definition.lock(*); end + definition.validate_runtime! - missing_specs = proc do - definition.missing_specs? - end + missing_specs = proc do + definition.missing_specs? + end - Bundler.ui = ui if install - if install || missing_specs.call - Bundler.settings.temporary(:inline => true) do - installer = Bundler::Installer.install(Bundler.root, definition, :system => true) - installer.post_install_messages.each do |name, message| - Bundler.ui.info "Post-install message from #{name}:\n#{message}" + Bundler.ui = ui if install + if install || missing_specs.call + Bundler.settings.temporary(:inline => true, :disable_platform_warnings => true) do + installer = Bundler::Installer.install(Bundler.root, definition, :system => true) + installer.post_install_messages.each do |name, message| + Bundler.ui.info "Post-install message from #{name}:\n#{message}" + end end end - end - runtime = Bundler::Runtime.new(nil, definition) - runtime.setup.require + runtime = Bundler::Runtime.new(nil, definition) + runtime.setup.require + end ensure bundler_module = class << Bundler; self; end bundler_module.send(:define_method, :root, old_root) if old_root diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 49143b38f9..5bc53a8b61 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -2,10 +2,10 @@ require "erb" require "rubygems/dependency_installer" -require "bundler/worker" -require "bundler/installer/parallel_installer" -require "bundler/installer/standalone" -require "bundler/installer/gem_installer" +require_relative "worker" +require_relative "installer/parallel_installer" +require_relative "installer/standalone" +require_relative "installer/gem_installer" module Bundler class Installer diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb index 469b15b96c..391540af0b 100644 --- a/lib/bundler/installer/parallel_installer.rb +++ b/lib/bundler/installer/parallel_installer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "bundler/worker" -require "bundler/installer/gem_installer" +require_relative "../worker" +require_relative "gem_installer" module Bundler class ParallelInstaller diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 69a721c120..cbd04b2c90 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require "uri" -require "bundler/match_platform" +require_relative "match_platform" module Bundler class LazySpecification diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb index 56cbbfb95d..69074925a6 100644 --- a/lib/bundler/match_platform.rb +++ b/lib/bundler/match_platform.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/gem_helpers" +require_relative "gem_helpers" module Bundler module MatchPlatform diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index 996d29aafb..02985fa9b0 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/plugin/api" +require_relative "plugin/api" module Bundler module Plugin diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb index faabf3a8d1..2d70a046bb 100644 --- a/lib/bundler/plugin/index.rb +++ b/lib/bundler/plugin/index.rb @@ -139,7 +139,7 @@ module Bundler data = index_f.read - require "bundler/yaml_serializer" + require_relative "../yaml_serializer" index = YAMLSerializer.load(data) @commands.merge!(index["commands"]) @@ -162,7 +162,7 @@ module Bundler "sources" => @sources, } - require "bundler/yaml_serializer" + require_relative "../yaml_serializer" SharedHelpers.filesystem_access(index_file) do |index_f| FileUtils.mkdir_p(index_f.dirname) File.open(index_f, "w") {|f| f.puts YAMLSerializer.dump(index) } diff --git a/lib/bundler/psyched_yaml.rb b/lib/bundler/psyched_yaml.rb index e654416a5a..c086b7651c 100644 --- a/lib/bundler/psyched_yaml.rb +++ b/lib/bundler/psyched_yaml.rb @@ -27,7 +27,7 @@ module Bundler end end -require "bundler/deprecate" +require_relative "deprecate" begin Bundler::Deprecate.skip_during do require "rubygems/safe_yaml" diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 90f833bef1..d3e5f268cf 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -2,8 +2,8 @@ module Bundler class Resolver - require "bundler/vendored_molinillo" - require "bundler/resolver/spec_group" + require_relative "vendored_molinillo" + require_relative "resolver/spec_group" # Figures out the best possible configuration of gems that satisfies # the list of passed dependencies and any child dependencies without diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index beed6372a3..df8646a2bb 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -8,7 +8,7 @@ require "rubygems/specification" # shouldn't be deferred. require "rubygems/source" -require "bundler/match_platform" +require_relative "match_platform" module Gem class Specification diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index ca7dd32611..32ddf185a0 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -111,7 +111,7 @@ module Bundler end def configuration - require "bundler/psyched_yaml" + require_relative "psyched_yaml" Gem.configuration rescue Gem::SystemExitException, LoadError => e Bundler.ui.error "#{e.class}: #{e.message}" @@ -261,7 +261,7 @@ module Bundler def spec_from_gem(path, policy = nil) require "rubygems/security" - require "bundler/psyched_yaml" + require_relative "psyched_yaml" gem_from_path(path, security_policies[policy]).spec rescue Gem::Package::FormatError raise GemspecError, "Could not read gem at #{path}. It may be corrupted." @@ -637,7 +637,7 @@ module Bundler end def all_specs - require "bundler/remote_specification" + require_relative "remote_specification" Gem::Specification.stubs.map do |stub| StubSpecification.from_stub(stub) end @@ -686,7 +686,7 @@ module Bundler def use_gemdeps(gemfile) ENV["BUNDLE_GEMFILE"] ||= File.expand_path(gemfile) - require "bundler/gemdeps" + require_relative "gemdeps" runtime = Bundler.setup Bundler.ui = nil activated_spec_names = runtime.requested_specs.map(&:to_spec).sort_by(&:name) diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index d21789dba1..2d0c4174ae 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -357,7 +357,7 @@ module Bundler return unless file SharedHelpers.filesystem_access(file) do |p| FileUtils.mkdir_p(p.dirname) - require "bundler/yaml_serializer" + require_relative "yaml_serializer" p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) } end end @@ -397,7 +397,7 @@ module Bundler SharedHelpers.filesystem_access(config_file, :read) do |file| valid_file = file.exist? && !file.size.zero? return {} unless valid_file - require "bundler/yaml_serializer" + require_relative "yaml_serializer" YAMLSerializer.load file.read end end diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb index 52a5b8889a..d156f494a8 100644 --- a/lib/bundler/setup.rb +++ b/lib/bundler/setup.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "bundler/shared_helpers" +require_relative "shared_helpers" if Bundler::SharedHelpers.in_bundle? - require "bundler" + require_relative "../bundler" if STDOUT.tty? || ENV["BUNDLER_FORCE_TTY"] Bundler.ui = Bundler::UI::Shell.new diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 1b703c5cbc..73c6dc3097 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -1,15 +1,15 @@ # frozen_string_literal: true -require "bundler/compatibility_guard" +require_relative "compatibility_guard" require "pathname" require "rbconfig" require "rubygems" -require "bundler/version" -require "bundler/constants" -require "bundler/rubygems_integration" -require "bundler/current_ruby" +require_relative "version" +require_relative "constants" +require_relative "rubygems_integration" +require_relative "current_ruby" module Bundler module SharedHelpers @@ -132,7 +132,7 @@ module Bundler def major_deprecation(major_version, message) bundler_major_version = Bundler.bundler_major_version if bundler_major_version > major_version - require "bundler/errors" + require_relative "errors" raise DeprecatedError, "[REMOVED] #{message}" end @@ -289,20 +289,10 @@ module Bundler public :set_env def set_bundle_variables - begin - exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) - unless File.exist?(exe_file) - exe_file = File.expand_path("../../../exe/bundle", __FILE__) - end - Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file - rescue Gem::GemNotFoundException - exe_file = File.expand_path("../../../exe/bundle", __FILE__) - # for Ruby core repository - exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file) - Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file - end - - # Set BUNDLE_GEMFILE + exe_file = File.expand_path("../../../exe/bundle", __FILE__) + # for Ruby core repository + exe_file = File.expand_path("../../../../bin/bundle", __FILE__) unless File.exist?(exe_file) + Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile(:order_matters).to_s Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION end @@ -351,9 +341,9 @@ module Bundler end def prints_major_deprecations? - require "bundler" + require_relative "../bundler" return false if Bundler.settings[:silence_deprecations] - require "bundler/deprecate" + require_relative "deprecate" return false if Bundler::Deprecate.skip true end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index a8afb341d8..aa24a87ed7 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/vendored_fileutils" +require_relative "../vendored_fileutils" require "uri" module Bundler diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb index bef94b505e..64b6d1b724 100644 --- a/lib/bundler/stub_specification.rb +++ b/lib/bundler/stub_specification.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/remote_specification" +require_relative "remote_specification" module Bundler class StubSpecification < RemoteSpecification diff --git a/lib/bundler/ui/rg_proxy.rb b/lib/bundler/ui/rg_proxy.rb index e2f98481db..ef6def225b 100644 --- a/lib/bundler/ui/rg_proxy.rb +++ b/lib/bundler/ui/rg_proxy.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/ui" +require_relative "../ui" require "rubygems/user_interaction" module Bundler diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index 7136fdfbf9..8e49fa5885 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/vendored_thor" +require_relative "../vendored_thor" module Bundler module UI diff --git a/lib/bundler/vendored_fileutils.rb b/lib/bundler/vendored_fileutils.rb index d14e98baf7..4b71759224 100644 --- a/lib/bundler/vendored_fileutils.rb +++ b/lib/bundler/vendored_fileutils.rb @@ -2,7 +2,7 @@ module Bundler; end if RUBY_VERSION >= "2.4" - require "bundler/vendor/fileutils/lib/fileutils" + require_relative "vendor/fileutils/lib/fileutils" else # the version we vendor is 2.4+ require "fileutils" diff --git a/lib/bundler/vendored_molinillo.rb b/lib/bundler/vendored_molinillo.rb index 061b634f72..d1976f5cb4 100644 --- a/lib/bundler/vendored_molinillo.rb +++ b/lib/bundler/vendored_molinillo.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true module Bundler; end -require "bundler/vendor/molinillo/lib/molinillo" +require_relative "vendor/molinillo/lib/molinillo" diff --git a/lib/bundler/vendored_persistent.rb b/lib/bundler/vendored_persistent.rb index de9c42fcc1..7670b83992 100644 --- a/lib/bundler/vendored_persistent.rb +++ b/lib/bundler/vendored_persistent.rb @@ -15,7 +15,7 @@ module Bundler end end end -require "bundler/vendor/net-http-persistent/lib/net/http/persistent" +require_relative "vendor/net-http-persistent/lib/net/http/persistent" module Bundler class PersistentHTTP < Persistent::Net::HTTP::Persistent diff --git a/lib/bundler/vendored_thor.rb b/lib/bundler/vendored_thor.rb index 8cca090f55..b0b7e7be84 100644 --- a/lib/bundler/vendored_thor.rb +++ b/lib/bundler/vendored_thor.rb @@ -5,4 +5,4 @@ module Bundler Kernel.send(:require, "bundler/vendor/thor/lib/thor/actions") end end -require "bundler/vendor/thor/lib/thor" +require_relative "vendor/thor/lib/thor" diff --git a/lib/bundler/vlad.rb b/lib/bundler/vlad.rb index 68181e7db8..538e8c3e74 100644 --- a/lib/bundler/vlad.rb +++ b/lib/bundler/vlad.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "bundler/shared_helpers" +require_relative "shared_helpers" Bundler::SharedHelpers.major_deprecation 2, "The Bundler task for Vlad" @@ -8,7 +8,7 @@ Bundler::SharedHelpers.major_deprecation 2, # # Add "require 'bundler/vlad'" in your Vlad deploy.rb, and # include the vlad:bundle:install task in your vlad:deploy task. -require "bundler/deployment" +require_relative "deployment" include Rake::DSL if defined? Rake::DSL diff --git a/man/bundle-add.ronn b/man/bundle-add.ronn index 1e2d732ec6..26cbe55647 100644 --- a/man/bundle-add.ronn +++ b/man/bundle-add.ronn @@ -3,7 +3,7 @@ bundle-add(1) -- Add gem to the Gemfile and run bundle install ## SYNOPSIS -`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--skip-install] [--strict] [--optimistic] +`bundle add` <GEM_NAME> [--group=GROUP] [--version=VERSION] [--source=SOURCE] [--git=GIT] [--branch=BRANCH] [--skip-install] [--strict] [--optimistic] ## DESCRIPTION Adds the named gem to the Gemfile and run `bundle install`. `bundle install` can be avoided by using the flag `--skip-install`. @@ -30,6 +30,12 @@ bundle add rails --group "development, test" * `--source`, , `-s`: Specify the source for the added gem. +* `--git`: + Specify the git source for the added gem. + +* `--branch`: + Specify the git branch for the added gem. + * `--skip-install`: Adds the gem to the Gemfile but does not install it. diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb index 7d435916db..f5b3f49bb1 100644 --- a/spec/commands/add_spec.rb +++ b/spec/commands/add_spec.rb @@ -11,6 +11,8 @@ RSpec.describe "bundle add" do build_gem "dog", "1.1.3.pre" end + build_git "foo", "2.0" + install_gemfile <<-G source "file://#{gem_repo2}" gem "weakling", "~> 0.0.1" @@ -89,6 +91,28 @@ RSpec.describe "bundle add" do end end + describe "with --git" do + it "adds dependency with specified github source" do + bundle "add foo --git=#{lib_path("foo-2.0")}" + + expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}"/) + expect(the_bundle).to include_gems "foo 2.0" + end + end + + describe "with --git and --branch" do + before do + update_git "foo", "2.0", :branch => "test" + end + + it "adds dependency with specified github source and branch" do + bundle "add foo --git=#{lib_path("foo-2.0")} --branch=test" + + expect(bundled_app("Gemfile").read).to match(/gem "foo", "~> 2.0", :git => "#{lib_path("foo-2.0")}", :branch => "test"/) + expect(the_bundle).to include_gems "foo 2.0" + end + end + describe "with --skip-install" do it "adds gem to Gemfile but is not installed" do bundle "add foo --skip-install --version=2.0" diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index e303b691b0..87279ebb74 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "set" + if defined?(Encoding) && Encoding.default_external.name != "UTF-8" # An approximation of ruby -E UTF-8, since it works on 1.8.7 Encoding.default_external = Encoding.find("UTF-8") @@ -273,4 +275,20 @@ RSpec.describe "The library itself" do expect(warnings).to be_well_formed end end + + it "does not use require internally, but require_relative" do + Dir.chdir(root) do + exempt = %r{templates/|vendor/} + all_bad_requires = [] + lib_files = ruby_core? ? `git ls-files -z -- lib/bundler lib/bundler.rb` : `git ls-files -z -- lib` + lib_files.split("\x0").each do |filename| + next if filename =~ exempt + File.readlines(filename).each_with_index do |line, number| + line.scan(/^ *require "bundler/).each { all_bad_requires << "#{filename}:#{number.succ}" } + end + end + + expect(all_bad_requires).to be_empty, "#{all_bad_requires.size} internal requires that should use `require_relative`: #{all_bad_requires}" + end + end end diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb index 5738c042bf..d53c3d1c15 100644 --- a/spec/runtime/inline_spec.rb +++ b/spec/runtime/inline_spec.rb @@ -244,6 +244,20 @@ RSpec.describe "bundler/inline#gemfile" do expect(exitstatus).to be_zero if exitstatus end + it "installs inline gems when frozen is set" do + script <<-RUBY, :env => { "BUNDLE_FROZEN" => "true" } + gemfile do + source "file://#{gem_repo1}" + gem "rack" + end + + puts RACK + RUBY + + expect(last_command.stderr).to be_empty + expect(exitstatus).to be_zero if exitstatus + end + it "installs inline gems when BUNDLE_GEMFILE is set to an empty string" do ENV["BUNDLE_GEMFILE"] = "" @@ -276,4 +290,17 @@ RSpec.describe "bundler/inline#gemfile" do expect(last_command).to be_success expect(out).to eq "1.0.0" end + + it "skips platform warnings" do + simulate_platform "ruby" + + script <<-RUBY + gemfile(true) do + source "file://#{gem_repo1}" + gem "rack", platform: :jruby + end + RUBY + + expect(err).to be_empty + end end diff --git a/task/release.rake b/task/release.rake index f22d1296cc..29fdc1dcb3 100644 --- a/task/release.rake +++ b/task/release.rake @@ -4,7 +4,7 @@ require "bundler/gem_tasks" task :build => ["build_metadata", "man:build", "generate_files"] do Rake::Task["build_metadata:clean"].tap(&:reenable).real_invoke end -task :release => ["man:require", "man:build", "release:verify_files", "release:verify_github", "build_metadata"] +task :release => ["man:build", "release:verify_files", "release:verify_github", "build_metadata"] namespace :release do task :verify_files do |