Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge latest stable versions of RubyGems/Bundler #8094

Merged
merged 10 commits into from Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 9 additions & 17 deletions lib/bundler.rb
Expand Up @@ -39,16 +39,6 @@ module Bundler
environment_preserver.replace_with_backup
SUDO_MUTEX = Thread::Mutex.new

SAFE_MARSHAL_CLASSES = [Symbol, TrueClass, String, Array, Hash, Gem::Version, Gem::Specification].freeze
SAFE_MARSHAL_ERROR = "Unexpected class %s present in marshaled data. Only %s are allowed."
SAFE_MARSHAL_PROC = proc do |object|
object.tap do
unless SAFE_MARSHAL_CLASSES.include?(object.class)
raise TypeError, format(SAFE_MARSHAL_ERROR, object.class, SAFE_MARSHAL_CLASSES.join(", "))
end
end
end

autoload :Definition, File.expand_path("bundler/definition", __dir__)
autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
Expand Down Expand Up @@ -86,10 +76,11 @@ module Bundler
autoload :UI, File.expand_path("bundler/ui", __dir__)
autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
autoload :URINormalizer, File.expand_path("bundler/uri_normalizer", __dir__)
autoload :SafeMarshal, File.expand_path("bundler/safe_marshal", __dir__)

class << self
def configure
@configured ||= configure_gem_home_and_path
@configure ||= configure_gem_home_and_path
end

def ui
Expand Down Expand Up @@ -219,9 +210,10 @@ def definition(unlock = nil)
end

def frozen_bundle?
frozen = settings[:deployment]
frozen ||= settings[:frozen]
frozen
frozen = settings[:frozen]
return frozen unless frozen.nil?

settings[:deployment]
end

def locked_gems
Expand Down Expand Up @@ -523,7 +515,7 @@ def read_file(file)
end

def safe_load_marshal(data)
load_marshal(data, :marshal_proc => SAFE_MARSHAL_PROC)
load_marshal(data, :marshal_proc => SafeMarshal.proc)
end

def load_gemspec(file, validate = false)
Expand All @@ -532,7 +524,7 @@ def load_gemspec(file, validate = false)
@gemspec_cache[key] ||= load_gemspec_uncached(file, validate)
# Protect against caching side-effected gemspecs by returning a
# new instance each time.
@gemspec_cache[key].dup if @gemspec_cache[key]
@gemspec_cache[key]&.dup
end

def load_gemspec_uncached(file, validate = false)
Expand Down Expand Up @@ -581,7 +573,7 @@ def reset_paths!
@bin_path = nil
@bundler_major_version = nil
@bundle_path = nil
@configured = nil
@configure = nil
@configured_bundle_path = nil
@definition = nil
@load = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/binstubs.rb
Expand Up @@ -11,7 +11,7 @@ def initialize(options, gems)
def run
Bundler.definition.validate_runtime!
path_option = options["path"]
path_option = nil if path_option && path_option.empty?
path_option = nil if path_option&.empty?
Bundler.settings.set_command_option :bin, path_option if options["path"]
Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
installer = Installer.new(Bundler.root, Bundler.definition)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/info.rb
Expand Up @@ -33,7 +33,7 @@ def spec_for_gem(gem_name)
def default_gem_spec(gem_name)
return unless Gem::Specification.respond_to?(:find_all_by_name)
gem_spec = Gem::Specification.find_all_by_name(gem_name).last
return gem_spec if gem_spec && gem_spec.respond_to?(:default_gem?) && gem_spec.default_gem?
return gem_spec if gem_spec&.default_gem?
end

def spec_not_found(gem_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/install.rb
Expand Up @@ -154,7 +154,7 @@ def normalize_settings
end

bin_option = options["binstubs"]
bin_option = nil if bin_option && bin_option.empty?
bin_option = nil if bin_option&.empty?
Bundler.settings.set_command_option :bin, bin_option if options["binstubs"]

Bundler.settings.set_command_option_if_given :shebang, options["shebang"]
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/outdated.rb
Expand Up @@ -194,7 +194,7 @@ def print_gem(current_spec, active_spec, dependency, groups)
end
current_version = "#{current_spec.version}#{current_spec.git_version}"

if dependency && dependency.specific?
if dependency&.specific?
dependency_version = %(, requested #{dependency.requirement})
end

Expand Down
12 changes: 7 additions & 5 deletions lib/bundler/cli/platform.rb
Expand Up @@ -8,12 +8,12 @@ def initialize(options)
end

def run
platforms, ruby_version = Bundler.ui.silence do
locked_ruby_version = Bundler.locked_gems && Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
gemfile_ruby_version = Bundler.definition.ruby_version && Bundler.definition.ruby_version.single_version_string
[Bundler.definition.platforms.map {|p| "* #{p}" },
locked_ruby_version || gemfile_ruby_version]
ruby_version = if Bundler.locked_gems
Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
else
Bundler.definition.ruby_version&.single_version_string
end

output = []

if options[:ruby]
Expand All @@ -23,6 +23,8 @@ def run
output << "No ruby version specified"
end
else
platforms = Bundler.definition.platforms.map {|p| "* #{p}" }

output << "Your platform is: #{Gem::Platform.local}"
output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"

Expand Down