[rubygems/rubygems] Only pristine executables for default gems
https://github.com/rubygems/rubygems/commit/1cfc1d626c
This commit is contained in:
parent
3d8fe462df
commit
1ad990a366
@ -137,6 +137,13 @@ extensions will be restored.
|
|||||||
specs.group_by(&:full_name_with_location).values.each do |grouped_specs|
|
specs.group_by(&:full_name_with_location).values.each do |grouped_specs|
|
||||||
spec = grouped_specs.find {|s| !s.default_gem? } || grouped_specs.first
|
spec = grouped_specs.find {|s| !s.default_gem? } || grouped_specs.first
|
||||||
|
|
||||||
|
unless only_executables_or_plugins?
|
||||||
|
# Default gemspecs include changes provided by ruby-core installer that
|
||||||
|
# can't currently be pristined (inclusion of compiled extension targets in
|
||||||
|
# the file list). So stick to resetting executables if it's a default gem.
|
||||||
|
options[:only_executables] = true if spec.default_gem?
|
||||||
|
end
|
||||||
|
|
||||||
if options.key? :skip
|
if options.key? :skip
|
||||||
if options[:skip].include? spec.name
|
if options[:skip].include? spec.name
|
||||||
say "Skipped #{spec.full_name}, it was given through options"
|
say "Skipped #{spec.full_name}, it was given through options"
|
||||||
@ -144,14 +151,14 @@ extensions will be restored.
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless spec.extensions.empty? || options[:extensions] || options[:only_executables] || options[:only_plugins]
|
unless spec.extensions.empty? || options[:extensions] || only_executables_or_plugins?
|
||||||
say "Skipped #{spec.full_name_with_location}, it needs to compile an extension"
|
say "Skipped #{spec.full_name_with_location}, it needs to compile an extension"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
gem = spec.cache_file
|
gem = spec.cache_file
|
||||||
|
|
||||||
unless File.exist?(gem) || options[:only_executables] || options[:only_plugins]
|
unless File.exist?(gem) || only_executables_or_plugins?
|
||||||
require_relative "../remote_fetcher"
|
require_relative "../remote_fetcher"
|
||||||
|
|
||||||
say "Cached gem for #{spec.full_name_with_location} not found, attempting to fetch..."
|
say "Cached gem for #{spec.full_name_with_location} not found, attempting to fetch..."
|
||||||
@ -185,7 +192,6 @@ extensions will be restored.
|
|||||||
env_shebang: env_shebang,
|
env_shebang: env_shebang,
|
||||||
build_args: spec.build_args,
|
build_args: spec.build_args,
|
||||||
bin_dir: bin_dir,
|
bin_dir: bin_dir,
|
||||||
install_as_default: spec.default_gem?,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if options[:only_executables]
|
if options[:only_executables]
|
||||||
@ -202,4 +208,10 @@ extensions will be restored.
|
|||||||
say "Restored #{spec.full_name_with_location}"
|
say "Restored #{spec.full_name_with_location}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def only_executables_or_plugins?
|
||||||
|
options[:only_executables] || options[:only_plugins]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -630,8 +630,16 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|||||||
|
|
||||||
def test_execute_default_gem
|
def test_execute_default_gem
|
||||||
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
default_gem_spec = new_default_spec("default", "2.0.0.0",
|
||||||
nil, "default/gem.rb")
|
nil, "exe/executable")
|
||||||
install_default_gems(default_gem_spec)
|
default_gem_spec.executables = "executable"
|
||||||
|
install_default_gems default_gem_spec
|
||||||
|
|
||||||
|
exe = File.join @gemhome, "bin", "executable"
|
||||||
|
|
||||||
|
assert_path_exist exe, "default gem's executable not installed"
|
||||||
|
|
||||||
|
content_with_replaced_shebang = File.read(exe).gsub(/^#![^\n]+ruby/, "#!/usr/bin/env ruby_executable_hooks")
|
||||||
|
File.write(exe, content_with_replaced_shebang)
|
||||||
|
|
||||||
@cmd.options[:args] = %w[default]
|
@cmd.options[:args] = %w[default]
|
||||||
|
|
||||||
@ -642,8 +650,7 @@ class TestGemCommandsPristineCommand < Gem::TestCase
|
|||||||
assert_equal(
|
assert_equal(
|
||||||
[
|
[
|
||||||
"Restoring gems to pristine condition...",
|
"Restoring gems to pristine condition...",
|
||||||
"Cached gem for default-2.0.0.0 not found, attempting to fetch...",
|
"Restored default-2.0.0.0",
|
||||||
"Skipped default-2.0.0.0, it was not found from cache and remote sources",
|
|
||||||
],
|
],
|
||||||
@ui.output.split("\n")
|
@ui.output.split("\n")
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user