Skip to content

Commit d03e422

Browse files
hsbtk0kubun
authored andcommitted
Merge RubyGems-3.5.21 and Bundler-2.5.21
1 parent af76568 commit d03e422

40 files changed

+276
-173
lines changed

lib/bundler.rb

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -383,28 +383,12 @@ def clean_env
383383

384384
# @return [Hash] Environment with all bundler-related variables removed
385385
def unbundled_env
386-
env = original_env
387-
388-
if env.key?("BUNDLER_ORIG_MANPATH")
389-
env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
390-
end
391-
392-
env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
393-
394-
if env.key?("RUBYOPT")
395-
rubyopt = env["RUBYOPT"].split(" ")
396-
rubyopt.delete("-r#{File.expand_path("bundler/setup", __dir__)}")
397-
rubyopt.delete("-rbundler/setup")
398-
env["RUBYOPT"] = rubyopt.join(" ")
399-
end
400-
401-
if env.key?("RUBYLIB")
402-
rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
403-
rubylib.delete(__dir__)
404-
env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
405-
end
386+
unbundle_env(original_env)
387+
end
406388

407-
env
389+
# Remove all bundler-related variables from ENV
390+
def unbundle_env!
391+
ENV.replace(unbundle_env(ENV))
408392
end
409393

410394
# Run block with environment present before Bundler was activated
@@ -633,6 +617,30 @@ def self_manager
633617

634618
private
635619

620+
def unbundle_env(env)
621+
if env.key?("BUNDLER_ORIG_MANPATH")
622+
env["MANPATH"] = env["BUNDLER_ORIG_MANPATH"]
623+
end
624+
625+
env.delete_if {|k, _| k[0, 7] == "BUNDLE_" }
626+
env.delete("BUNDLER_SETUP")
627+
628+
if env.key?("RUBYOPT")
629+
rubyopt = env["RUBYOPT"].split(" ")
630+
rubyopt.delete("-r#{File.expand_path("bundler/setup", __dir__)}")
631+
rubyopt.delete("-rbundler/setup")
632+
env["RUBYOPT"] = rubyopt.join(" ")
633+
end
634+
635+
if env.key?("RUBYLIB")
636+
rubylib = env["RUBYLIB"].split(File::PATH_SEPARATOR)
637+
rubylib.delete(__dir__)
638+
env["RUBYLIB"] = rubylib.join(File::PATH_SEPARATOR)
639+
end
640+
641+
env
642+
end
643+
636644
def load_marshal(data, marshal_proc: nil)
637645
Marshal.load(data, marshal_proc)
638646
rescue TypeError => e

lib/bundler/inline.rb

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ def gemfile(install = false, options = {}, &gemfile)
3939
Bundler.ui = ui
4040
raise ArgumentError, "Unknown options: #{opts.keys.join(", ")}" unless opts.empty?
4141

42-
Bundler.with_unbundled_env do
42+
old_gemfile = ENV["BUNDLE_GEMFILE"]
43+
44+
Bundler.unbundle_env!
45+
46+
begin
4347
Bundler.instance_variable_set(:@bundle_path, Pathname.new(Gem.dir))
4448
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", "Gemfile"
4549

@@ -80,9 +84,11 @@ def gemfile(install = false, options = {}, &gemfile)
8084

8185
runtime.require
8286
end
83-
end
84-
85-
if ENV["BUNDLE_GEMFILE"].nil?
86-
ENV["BUNDLE_GEMFILE"] = ""
87+
ensure
88+
if old_gemfile
89+
ENV["BUNDLE_GEMFILE"] = old_gemfile
90+
else
91+
ENV["BUNDLE_GEMFILE"] = ""
92+
end
8793
end
8894
end

lib/bundler/source/git.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def specs(*)
191191
set_up_app_cache!(app_cache_path) if use_app_cache?
192192

193193
if requires_checkout? && !@copied
194-
FileUtils.rm_rf(app_cache_path) if use_app_cache? && git_proxy.not_a_bare_repository?
194+
FileUtils.rm_rf(app_cache_path) if use_app_cache? && git_proxy.not_a_repository?
195195

196196
fetch
197197
checkout

lib/bundler/source/git/git_proxy.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ def current_branch
8484
end
8585
end
8686

87-
def not_a_bare_repository?
88-
git_local("rev-parse", "--is-bare-repository", dir: path).strip == "false"
87+
def not_a_repository?
88+
_, status = git_null("rev-parse", "--resolve-git-dir", path.to_s, dir: path)
89+
90+
!status.success?
8991
end
9092

9193
def contains?(commit)

lib/bundler/source/path.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def to_s
5353
"source at `#{@path}`"
5454
end
5555

56+
alias_method :to_gemfile, :path
57+
5658
def hash
5759
[self.class, expanded_path, version].hash
5860
end

lib/bundler/stub_specification.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def missing_extensions?
4545
true
4646
end
4747

48-
def activated
49-
stub.activated
48+
def activated?
49+
stub.activated?
5050
end
5151

5252
def activated=(activated)

lib/bundler/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: false
22

33
module Bundler
4-
VERSION = "2.5.20".freeze
4+
VERSION = "2.5.21".freeze
55

66
def self.bundler_major_version
77
@bundler_major_version ||= VERSION.split(".").first.to_i

lib/rubygems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
require "rbconfig"
1010

1111
module Gem
12-
VERSION = "3.5.20"
12+
VERSION = "3.5.21"
1313
end
1414

1515
# Must be first since it unloads the prelude from 1.9.2

lib/rubygems/command_manager.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,11 @@ def find_command_possibilities(cmd_name)
230230
def load_and_instantiate(command_name)
231231
command_name = command_name.to_s
232232
const_name = command_name.capitalize.gsub(/_(.)/) { $1.upcase } << "Command"
233-
load_error = nil
234233

235234
begin
236-
begin
237-
require "rubygems/commands/#{command_name}_command"
238-
rescue LoadError => e
239-
load_error = e
240-
end
235+
require "rubygems/commands/#{command_name}_command"
241236
Gem::Commands.const_get(const_name).new
242-
rescue StandardError => e
243-
e = load_error if load_error
244-
237+
rescue StandardError, LoadError => e
245238
alert_error clean_text("Loading command: #{command_name} (#{e.class})\n\t#{e}")
246239
ui.backtrace e
247240
end

lib/rubygems/commands/cleanup_command.rb

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ def initialize
3838
@default_gems = []
3939
@full = nil
4040
@gems_to_cleanup = nil
41-
@original_home = nil
42-
@original_path = nil
4341
@primary_gems = nil
4442
end
4543

@@ -95,9 +93,6 @@ def execute
9593
end
9694

9795
def clean_gems
98-
@original_home = Gem.dir
99-
@original_path = Gem.path
100-
10196
get_primary_gems
10297
get_candidate_gems
10398
get_gems_to_cleanup
@@ -112,8 +107,6 @@ def clean_gems
112107
deps.reverse_each do |spec|
113108
uninstall_dep spec
114109
end
115-
116-
Gem::Specification.reset
117110
end
118111

119112
def get_candidate_gems
@@ -133,7 +126,7 @@ def get_gems_to_cleanup
133126

134127
default_gems, gems_to_cleanup = gems_to_cleanup.partition(&:default_gem?)
135128

136-
uninstall_from = options[:user_install] ? Gem.user_dir : @original_home
129+
uninstall_from = options[:user_install] ? Gem.user_dir : Gem.dir
137130

138131
gems_to_cleanup = gems_to_cleanup.select do |spec|
139132
spec.base_dir == uninstall_from
@@ -181,8 +174,5 @@ def uninstall_dep(spec)
181174
say "Unable to uninstall #{spec.full_name}:"
182175
say "\t#{e.class}: #{e.message}"
183176
end
184-
ensure
185-
# Restore path Gem::Uninstaller may have changed
186-
Gem.use_paths @original_home, *@original_path
187177
end
188178
end

0 commit comments

Comments
 (0)