Skip to content

Commit

Permalink
[rubygems/rubygems] Extract some common strings to variables
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Dec 12, 2023
1 parent a811ebf commit 23289ad
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/rubygems/commands/setup_command.rb
Expand Up @@ -374,21 +374,24 @@ def install_default_bundler_gem(bin_dir)
end

bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
default_spec_path = File.join(specs_dir, "#{bundler_spec.full_name}.gemspec")
full_name = bundler_spec.full_name
gemspec_path = "#{full_name}.gemspec"

default_spec_path = File.join(specs_dir, gemspec_path)
Gem.write_binary(default_spec_path, bundler_spec.to_ruby)

bundler_spec = Gem::Specification.load(default_spec_path)

# Remove gemspec that was same version of vendored bundler.
normal_gemspec = File.join(default_dir, "specifications", "bundler-#{bundler_spec.version}.gemspec")
normal_gemspec = File.join(default_dir, "specifications", gemspec_path)
if File.file? normal_gemspec
File.delete normal_gemspec
end

# Remove gem files that were same version of vendored bundler.
if File.directory? bundler_spec.gems_dir
Dir.entries(bundler_spec.gems_dir).
select {|default_gem| File.basename(default_gem) == "bundler-#{bundler_spec.version}" }.
select {|default_gem| File.basename(default_gem) == full_name }.
each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) }
end

Expand Down

0 comments on commit 23289ad

Please sign in to comment.