Skip to content

Commit

Permalink
Sychronize with rubygems/rubygems repo
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and ko1 committed May 31, 2024
1 parent 89486c7 commit 10c256f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
13 changes: 13 additions & 0 deletions lib/rubygems/basic_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ def full_name
end
end

##
# Returns the full name of this Gem (see `Gem::BasicSpecification#full_name`).
# Information about where the gem is installed is also included if not
# installed in the default GEM_HOME.

def full_name_with_location
if base_dir != Gem.dir
"#{full_name} in #{base_dir}"
else
full_name
end
end

##
# Full paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
# activated.
Expand Down
6 changes: 3 additions & 3 deletions lib/rubygems/commands/pristine_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def execute
end

unless spec.extensions.empty? || options[:extensions] || options[:only_executables] || options[:only_plugins]
say "Skipped #{spec.full_name}, it needs to compile an extension"
say "Skipped #{spec.full_name_with_location}, it needs to compile an extension"
next
end

Expand All @@ -157,7 +157,7 @@ def execute
unless File.exist?(gem) || options[:only_executables] || options[:only_plugins]
require_relative "../remote_fetcher"

say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
say "Cached gem for #{spec.full_name_with_location} not found, attempting to fetch..."

dep = Gem::Dependency.new spec.name, spec.version
found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
Expand Down Expand Up @@ -201,7 +201,7 @@ def execute
installer.install
end

say "Restored #{spec.full_name}"
say "Restored #{spec.full_name_with_location}"
end
end
end
1 change: 0 additions & 1 deletion lib/rubygems/specification_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def stubs_for_pattern(pattern, match_platform = true)
installed_stubs = installed_stubs(pattern)
installed_stubs.select! {|s| Gem::Platform.match_spec? s } if match_platform
stubs = installed_stubs + Gem::Specification.default_stubs(pattern)
stubs = stubs.uniq(&:full_name)
Gem::Specification._resort!(stubs)
stubs
end
Expand Down
10 changes: 5 additions & 5 deletions test/rubygems/test_gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1562,20 +1562,20 @@ def test_gem_path_ordering
assert_equal m1.gem_dir, File.join(Gem.user_dir, "gems", "m-1")

tests = [
[:dir0, [Gem.dir, Gem.user_dir], m0],
[:dir1, [Gem.user_dir, Gem.dir], m1],
[:dir0, [Gem.dir, Gem.user_dir]],
[:dir1, [Gem.user_dir, Gem.dir]],
]

tests.each do |name, paths, expected|
tests.each do |name, paths|
Gem.use_paths paths.first, paths
Gem.searcher = nil

assert_equal Gem::Dependency.new("m","1").to_specs,
Gem::Dependency.new("m","1").to_specs.sort

assert_equal \
[expected.gem_dir],
Gem::Dependency.new("m","1").to_specs.map(&:gem_dir).sort,
[m0.gem_dir, m1.gem_dir],
Gem::Dependency.new("m","1").to_specs.map(&:gem_dir).uniq.sort,
"Wrong specs for #{name}"

spec = Gem::Dependency.new("m","1").to_spec
Expand Down
11 changes: 6 additions & 5 deletions test/rubygems/test_gem_commands_pristine_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_execute_user_install
out = @ui.output.split("\n")

assert_equal "Restoring gems to pristine condition...", out.shift
assert_equal "Restored #{a.full_name}", out.shift
assert_equal "Restored #{a.full_name} in #{Gem.user_dir}", out.shift
assert_empty out, out.inspect
ensure
FileUtils.chmod(0o755, @gemhome)
Expand Down Expand Up @@ -404,7 +404,7 @@ def test_execute_many_multi_repo
out = @ui.output.split "\n"

assert_equal "Restoring gems to pristine condition...", out.shift
assert_equal "Restored #{a.full_name}", out.shift
assert_equal "Restored #{a.full_name} in #{@gemhome}", out.shift
assert_equal "Restored #{b.full_name}", out.shift
assert_empty out, out.inspect

Expand Down Expand Up @@ -476,8 +476,9 @@ def test_execute_missing_cache_gem_when_multi_repo

[
"Restoring gems to pristine condition...",
"Cached gem for a-1 not found, attempting to fetch...",
"Restored a-1",
"Cached gem for a-1 in #{@gemhome} not found, attempting to fetch...",
"Restored a-1 in #{@gemhome}",
"Restored b-1 in #{@gemhome}",
"Cached gem for b-1 not found, attempting to fetch...",
"Restored b-1",
].each do |line|
Expand All @@ -495,7 +496,7 @@ def test_execute_missing_cache_gem_when_multi_repo
assert_path_exist File.join(gemhome2, "cache", "b-1.gem")
assert_path_not_exist File.join(@gemhome, "cache", "b-2.gem")
assert_path_exist File.join(gemhome2, "gems", "b-1")
assert_path_not_exist File.join(@gemhome, "gems", "b-1")
assert_path_exist File.join(@gemhome, "gems", "b-1")
end

def test_execute_no_gem
Expand Down

0 comments on commit 10c256f

Please sign in to comment.