Skip to content

Commit

Permalink
Merge bundler-2.2.0.rc.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbt committed Oct 15, 2020
1 parent 7ffd14a commit d386a58
Show file tree
Hide file tree
Showing 200 changed files with 1,058 additions and 3,672 deletions.
9 changes: 6 additions & 3 deletions lib/bundler.rb
Expand Up @@ -353,7 +353,10 @@ def unbundled_env
env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }

if env.key?("RUBYOPT")
env["RUBYOPT"] = env["RUBYOPT"].sub "-rbundler/setup", ""
rubyopt = env["RUBYOPT"].split(" ")
rubyopt.delete("-r#{File.expand_path("bundler/setup", __dir__)}")
rubyopt.delete("-rbundler/setup")
env["RUBYOPT"] = rubyopt.join(" ")
end

if env.key?("RUBYLIB")
Expand Down Expand Up @@ -453,7 +456,7 @@ def system_bindir
# system binaries. If you put '-n foo' in your .gemrc, RubyGems will
# install binstubs there instead. Unfortunately, RubyGems doesn't expose
# that directory at all, so rather than parse .gemrc ourselves, we allow
# the directory to be set as well, via `bundle config set bindir foo`.
# the directory to be set as well, via `bundle config set --local bindir foo`.
Bundler.settings[:system_bindir] || Bundler.rubygems.gem_bindir
end

Expand Down Expand Up @@ -621,7 +624,7 @@ def reset_rubygems!
@rubygems = nil
end

private
private

def eval_yaml_gemspec(path, contents)
require_relative "bundler/psyched_yaml"
Expand Down
10 changes: 1 addition & 9 deletions lib/bundler/build_metadata.rb
Expand Up @@ -27,19 +27,11 @@ def self.git_commit_sha

# If Bundler has been installed without its .git directory and without a
# commit instance variable then we can't determine its commits SHA.
git_dir = File.join(File.expand_path("../../..", __FILE__), ".git")
git_dir = File.join(File.expand_path("../../../..", __FILE__), ".git")
if File.directory?(git_dir)
return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze }
end

# If Bundler is a submodule in RubyGems, get the submodule commit
git_sub_dir = File.join(File.expand_path("../../../..", __FILE__), ".git")
if File.directory?(git_sub_dir)
return @git_commit_sha = Dir.chdir(git_sub_dir) do
`git ls-tree --abbrev=8 HEAD bundler`.split(/\s/).fetch(2, "").strip.freeze
end
end

@git_commit_sha ||= "unknown"
end

Expand Down
41 changes: 27 additions & 14 deletions lib/bundler/cli.rb
Expand Up @@ -134,7 +134,7 @@ def help(cli = nil)
if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
Kernel.exec "man #{man_page}"
else
puts File.read("#{File.dirname(man_page)}/#{File.basename(man_page)}.txt")
puts File.read("#{File.dirname(man_page)}/#{File.basename(man_page)}.ronn")
end
elsif command_path = Bundler.which("bundler-#{cli}")
Kernel.exec(command_path, "--help")
Expand Down Expand Up @@ -439,11 +439,18 @@ def outdated(*gems)
Outdated.new(options, gems).run
end

desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
unless Bundler.feature_flag.cache_all?
method_option "all", :type => :boolean,
:banner => "Include all sources (including path and git)."
desc "fund [OPTIONS]", "Lists information about gems seeking funding assistance"
method_option "group", :aliases => "-g", :type => :array, :banner =>
"Fetch funding information for a specific group"
def fund
require_relative "cli/fund"
Fund.new(options).run
end

desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
method_option "all", :type => :boolean,
:default => Bundler.feature_flag.cache_all?,
:banner => "Include all sources (including path and git)."
method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
method_option "cache-path", :type => :string, :banner =>
"Specify a different cache path than the default (vendor/cache)."
Expand All @@ -462,6 +469,12 @@ def outdated(*gems)
bundle without having to download any additional gems.
D
def cache
SharedHelpers.major_deprecation 2,
"The `--all` flag is deprecated because it relies on being " \
"remembered across bundler invocations, which bundler will no longer " \
"do in future versions. Instead please use `bundle config set cache_all true`, " \
"and stop using this flag" if ARGV.include?("--all")

require_relative "cli/cache"
Cache.new(options).run
end
Expand Down Expand Up @@ -565,18 +578,18 @@ def viz

desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
method_option :exe, :type => :boolean, :default => false, :aliases => ["--bin", "-b"], :desc => "Generate a binary executable for your library."
method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config set gem.coc true`."
method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config set --global gem.coc true`."
method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
:lazy_default => [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? },
:desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
method_option :ext, :type => :boolean, :default => false, :desc => "Generate the boilerplate for C extension code"
method_option :git, :type => :boolean, :default => true, :desc => "Initialize a git repo inside your library."
method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set gem.mit true`."
method_option :rubocop, :type => :boolean, :desc => "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set gem.rubocop true`."
method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
method_option :rubocop, :type => :boolean, :desc => "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
method_option :test, :type => :string, :lazy_default => Bundler.settings["gem.test"] || "", :aliases => "-t", :banner => "Use the specified test framework for your library",
:desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set gem.test (rspec|minitest|test-unit)`."
:desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
:desc => "Generate CI configuration, either GitHub Actions, Travis CI, GitLab CI or CircleCI. Set a default with `bundle config set gem.ci (github|travis|gitlab|circle)`"
:desc => "Generate CI configuration, either GitHub Actions, Travis CI, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|travis|gitlab|circle)`"

def gem(name)
end
Expand Down Expand Up @@ -740,11 +753,11 @@ def self.reformatted_help_args(args)
end
end

private
private

# Automatically invoke `bundle install` and resume if
# Bundler.settings[:auto_install] exists. This is set through config cmd
# `bundle config set auto_install 1`.
# `bundle config set --global auto_install 1`.
#
# Note that this method `nil`s out the global Definition object, so it
# should be called first, before you instantiate anything like an
Expand Down Expand Up @@ -839,10 +852,10 @@ def flag_deprecation(name, flag_name, option)
value = options[name]
value = value.join(" ").to_s if option.type == :array

Bundler::SharedHelpers.major_deprecation 2,\
Bundler::SharedHelpers.major_deprecation 2,
"The `#{flag_name}` flag is deprecated because it relies on being " \
"remembered across bundler invocations, which bundler will no longer " \
"do in future versions. Instead please use `bundle config set #{name.tr("-", "_")} " \
"do in future versions. Instead please use `bundle config set --local #{name.tr("-", "_")} " \
"'#{value}'`, and stop using this flag"
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/add.rb
Expand Up @@ -17,7 +17,7 @@ def run
perform_bundle_install unless options["skip-install"]
end

private
private

def perform_bundle_install
Installer.install(Bundler.root, Bundler.definition)
Expand Down
8 changes: 1 addition & 7 deletions lib/bundler/cli/cache.rb
Expand Up @@ -24,7 +24,7 @@ def run
end
end

private
private

def install
require_relative "install"
Expand All @@ -37,12 +37,6 @@ def setup_cache_all
all = options.fetch(:all, Bundler.feature_flag.cache_all? || nil)

Bundler.settings.set_command_option_if_given :cache_all, all

if Bundler.definition.has_local_dependencies? && !Bundler.feature_flag.cache_all?
Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
"to cache them as well, please pass the --all flag. This will be the default " \
"on Bundler 3.0."
end
end
end
end
2 changes: 1 addition & 1 deletion lib/bundler/cli/clean.rb
Expand Up @@ -13,7 +13,7 @@ def run
Bundler.load.clean(options[:"dry-run"])
end

protected
protected

def require_path_or_force
return unless Bundler.use_system_gems? && !options[:force]
Expand Down
14 changes: 14 additions & 0 deletions lib/bundler/cli/common.rb
Expand Up @@ -14,6 +14,20 @@ def self.print_post_install_message(name, msg)
Bundler.ui.info msg
end

def self.output_fund_metadata_summary
definition = Bundler.definition
current_dependencies = definition.requested_dependencies
current_specs = definition.specs

count = current_dependencies.count {|dep| current_specs[dep.name].first.metadata.key?("funding_uri") }

return if count.zero?

intro = count > 1 ? "#{count} installed gems you directly depend on are" : "#{count} installed gem you directly depend on is"
message = "#{intro} looking for funding.\n Run `bundle fund` for details"
Bundler.ui.info message
end

def self.output_without_groups_message(command)
return if Bundler.settings[:without].empty?
Bundler.ui.confirm without_groups_message(command)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/doctor.rb
Expand Up @@ -93,7 +93,7 @@ def run
end
end

private
private

def check_home_permissions
require "find"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/exec.rb
Expand Up @@ -34,7 +34,7 @@ def run
end
end

private
private

def validate_cmd!
return unless cmd.nil?
Expand Down
36 changes: 36 additions & 0 deletions lib/bundler/cli/fund.rb
@@ -0,0 +1,36 @@
# frozen_string_literal: true

module Bundler
class CLI::Fund
attr_reader :options

def initialize(options)
@options = options
end

def run
Bundler.definition.validate_runtime!

groups = Array(options[:group]).map(&:to_sym)

deps = if groups.any?
Bundler.definition.dependencies_for(groups)
else
Bundler.definition.current_dependencies
end

fund_info = deps.each_with_object([]) do |dep, arr|
spec = Bundler.definition.specs[dep.name].first
if spec.metadata.key?("funding_uri")
arr << "* #{spec.name} (#{spec.version})\n Funding: #{spec.metadata["funding_uri"]}"
end
end

if fund_info.empty?
Bundler.ui.info "None of the installed gems you directly depend on are looking for funding."
else
Bundler.ui.info fund_info.join("\n")
end
end
end
end
2 changes: 1 addition & 1 deletion lib/bundler/cli/gem.rb
Expand Up @@ -192,7 +192,7 @@ def run
raise GenericSystemCallError.new(e, "There was a conflict while creating the new gem.")
end

private
private

def resolve_name(name)
SharedHelpers.pwd.join(name).basename.to_s
Expand Down
3 changes: 2 additions & 1 deletion lib/bundler/cli/info.rb
Expand Up @@ -22,7 +22,7 @@ def run
end
end

private
private

def spec_for_gem(gem_name)
spec = Bundler.definition.specs.find {|s| s.name == gem_name }
Expand Down Expand Up @@ -60,6 +60,7 @@ def print_gem_info(spec)
gem_info << "\tHomepage: #{spec.homepage}\n" if spec.homepage
gem_info << "\tDocumentation: #{metadata["documentation_uri"]}\n" if metadata.key?("documentation_uri")
gem_info << "\tSource Code: #{metadata["source_code_uri"]}\n" if metadata.key?("source_code_uri")
gem_info << "\tFunding: #{metadata["funding_uri"]}\n" if metadata.key?("funding_uri")
gem_info << "\tWiki: #{metadata["wiki_uri"]}\n" if metadata.key?("wiki_uri")
gem_info << "\tChangelog: #{metadata["changelog_uri"]}\n" if metadata.key?("changelog_uri")
gem_info << "\tBug Tracker: #{metadata["bug_tracker_uri"]}\n" if metadata.key?("bug_tracker_uri")
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/init.rb
Expand Up @@ -38,7 +38,7 @@ def run
puts "Writing new #{gemfile} to #{SharedHelpers.pwd}/#{gemfile}"
end

private
private

def gemfile
@gemfile ||= Bundler.preferred_gemfile_name
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/inject.rb
Expand Up @@ -44,7 +44,7 @@ def run
end
end

private
private

def last_version_number
definition = Bundler.definition(true)
Expand Down
6 changes: 4 additions & 2 deletions lib/bundler/cli/install.rb
Expand Up @@ -53,7 +53,7 @@ def run

if options["binstubs"]
Bundler::SharedHelpers.major_deprecation 2,
"The --binstubs option will be removed in favor of `bundle binstubs`"
"The --binstubs option will be removed in favor of `bundle binstubs --all`"
end

Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
Expand Down Expand Up @@ -82,6 +82,8 @@ def run
require_relative "clean"
Bundler::CLI::Clean.new(options).run
end

Bundler::CLI::Common.output_fund_metadata_summary
rescue GemNotFound, VersionConflict => e
if options[:local] && Bundler.app_cache.exist?
Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
Expand All @@ -100,7 +102,7 @@ def run
raise e
end

private
private

def warn_if_root
return if Bundler.settings[:silence_root_warning] || Bundler::WINDOWS || !Process.uid.zero?
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/list.rb
Expand Up @@ -31,7 +31,7 @@ def run
Bundler.ui.info "Use `bundle info` to print more detailed information about a gem"
end

private
private

def verify_group_exists(groups)
(@without_group + @only_group).each do |group|
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/outdated.rb
Expand Up @@ -127,7 +127,7 @@ def run
end
end

private
private

def groups_text(group_text, groups)
"#{group_text}#{groups.split(",").size > 1 ? "s" : ""} \"#{groups}\""
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/show.rb
Expand Up @@ -53,7 +53,7 @@ def run
end
end

private
private

def fetch_latest_specs
definition = Bundler.definition(true)
Expand Down
2 changes: 2 additions & 0 deletions lib/bundler/cli/update.rb
Expand Up @@ -106,6 +106,8 @@ def run
Bundler.ui.confirm "Bundle updated!"
Bundler::CLI::Common.output_without_groups_message(:update)
Bundler::CLI::Common.output_post_install_messages installer.post_install_messages

Bundler::CLI::Common.output_fund_metadata_summary
end
end
end
2 changes: 1 addition & 1 deletion lib/bundler/compact_index_client.rb
Expand Up @@ -87,7 +87,7 @@ def update_and_parse_checksums!
@parsed_checksums = true
end

private
private

def update(local_path, remote_path)
Bundler::CompactIndexClient.debug { "update(#{local_path}, #{remote_path})" }
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/compact_index_client/cache.rb
Expand Up @@ -83,7 +83,7 @@ def specific_dependency(name, version, platform)
gem_line ? parse_gem(gem_line) : nil
end

private
private

def lines(path)
return [] unless path.file?
Expand Down

0 comments on commit d386a58

Please sign in to comment.