* lib/rubygems: Update to RubyGems 2.4.6 and HEAD(800f2e6).

Fixed #1159, #1171, #1173 on rubygems/rubygems
* test/rubygems: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
hsbt 2015-02-27 13:00:45 +00:00
Родитель b89e894399
Коммит d9c32d62a0
17 изменённых файлов: 205 добавлений и 155 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Fri Feb 27 22:00:05 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* lib/rubygems: Update to RubyGems 2.4.6 and HEAD(800f2e6).
Fixed #1159, #1171, #1173 on rubygems/rubygems
* test/rubygems: ditto.
Fri Feb 27 20:55:42 2015 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* lib/rake: Update to rake (9237e74), typo fix and remove needless

Просмотреть файл

@ -21,6 +21,11 @@ class Gem::Commands::PristineCommand < Gem::Command
options[:all] = value
end
add_option('--skip=gem_name',
'used on --all, skip if name == gem_name') do |value, options|
options[:skip] = value
end
add_option('--[no-]extensions',
'Restore gems with extensions',
'in addition to regular gems') do |value, options|
@ -109,6 +114,11 @@ extensions will be restored.
next
end
if spec.name == options[:skip]
say "Skipped #{spec.full_name}, it was given through options"
next
end
if spec.bundled_gem_in_old_ruby?
say "Skipped #{spec.full_name}, it is bundled with old Ruby"
next

Просмотреть файл

@ -92,23 +92,6 @@ class Gem::Indexer
@files = []
end
##
# Abbreviate the spec for downloading. Abbreviated specs are only used for
# searching, downloading and related activities and do not need deployment
# specific information (e.g. list of files). So we abbreviate the spec,
# making it much smaller for quicker downloads.
#--
# TODO move to Gem::Specification
def abbreviate(spec)
spec.files = []
spec.test_files = []
spec.rdoc_options = []
spec.extra_rdoc_files = []
spec.cert_chain = []
spec
end
##
# Build various indicies
@ -221,18 +204,8 @@ class Gem::Indexer
spec = Gem::Package.new(gemfile).spec
spec.loaded_from = gemfile
# HACK: fuck this shit - borks all tests that use pl1
# if File.basename(gemfile, ".gem") != spec.original_name then
# exp = spec.full_name
# exp << " (#{spec.original_name})" if
# spec.original_name != spec.full_name
# msg = "Skipping misnamed gem: #{gemfile} should be named #{exp}"
# alert_warning msg
# next
# end
abbreviate spec
sanitize spec
spec.abbreviate
spec.sanitize
spec
rescue SignalException
@ -380,38 +353,6 @@ class Gem::Indexer
end
end
##
# Sanitize the descriptive fields in the spec. Sometimes non-ASCII
# characters will garble the site index. Non-ASCII characters will
# be replaced by their XML entity equivalent.
def sanitize(spec)
spec.summary = sanitize_string(spec.summary)
spec.description = sanitize_string(spec.description)
spec.post_install_message = sanitize_string(spec.post_install_message)
spec.authors = spec.authors.collect { |a| sanitize_string(a) }
spec
end
##
# Sanitize a single string.
def sanitize_string(string)
return string unless string
# HACK the #to_s is in here because RSpec has an Array of Arrays of
# Strings for authors. Need a way to disallow bad values on gemspec
# generation. (Probably won't happen.)
string = string.to_s
begin
Builder::XChar.encode string
rescue NameError, NoMethodError
string.to_xs
end
end
##
# Perform an in-place update of the repository from newly added gems.

Просмотреть файл

@ -366,8 +366,9 @@ EOM
FileUtils.mkdir_p mkdir, mkdir_options
open destination, 'wb', entry.header.mode do |out|
open destination, 'wb' do |out|
out.write entry.read
FileUtils.chmod entry.header.mode, destination
end if entry.file?
verbose destination

Просмотреть файл

@ -223,7 +223,7 @@ class Gem::RequestSet
if options.fetch :lock, true then
lockfile =
Gem::RequestSet::Lockfile.new self, gemdeps, gem_deps_api.dependencies
Gem::RequestSet::Lockfile.build self, gemdeps, gem_deps_api.dependencies
lockfile.write
end
@ -275,7 +275,7 @@ class Gem::RequestSet
@git_set.root_dir = @install_dir
lock_file = "#{File.expand_path(path)}.lock"
lock_file = "#{File.expand_path(path)}.lock".untaint
begin
tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file
parser = tokenizer.make_parser self, []

Просмотреть файл

@ -367,11 +367,11 @@ class Gem::RequestSet::GemDependencyAPI
@dependencies[name] =
if requirements.empty? and not source_set then
nil
Gem::Requirement.default
elsif source_set then
'!'
Gem::Requirement.source_set
else
requirements
Gem::Requirement.create requirements
end
return unless gem_platforms options
@ -601,7 +601,7 @@ Gem dependencies file #{@path} requires #{name} more than once.
add_dependencies groups, [self_dep]
add_dependencies groups, spec.runtime_dependencies
@dependencies[spec.name] = '!'
@dependencies[spec.name] = Gem::Requirement.source_set
spec.dependencies.each do |dep|
@dependencies[dep.name] = dep.requirement

Просмотреть файл

@ -36,16 +36,41 @@ class Gem::RequestSet::Lockfile
end
end
##
# Creates a new Lockfile for the given +request_set+ and +gem_deps_file+
# location.
def self.build request_set, gem_deps_file, dependencies = nil
request_set.resolve
dependencies ||= requests_to_deps request_set.sorted_requests
new request_set, gem_deps_file, dependencies
end
def self.requests_to_deps requests # :nodoc:
deps = {}
requests.each do |request|
spec = request.spec
name = request.name
requirement = request.request.dependency.requirement
deps[name] = if [Gem::Resolver::VendorSpecification,
Gem::Resolver::GitSpecification].include? spec.class then
Gem::Requirement.source_set
else
requirement
end
end
deps
end
##
# The platforms for this Lockfile
attr_reader :platforms
##
# Creates a new Lockfile for the given +request_set+ and +gem_deps_file+
# location.
def initialize request_set, gem_deps_file, dependencies = nil
def initialize request_set, gem_deps_file, dependencies
@set = request_set
@dependencies = dependencies
@gem_deps_file = File.expand_path(gem_deps_file)
@ -59,41 +84,9 @@ class Gem::RequestSet::Lockfile
def add_DEPENDENCIES out # :nodoc:
out << "DEPENDENCIES"
dependencies =
if @dependencies then
@dependencies.sort_by { |name,| name }.map do |name, requirement|
requirement_string =
if '!' == requirement then
requirement
else
Gem::Requirement.new(requirement).for_lockfile
end
[name, requirement_string]
end
else
requests.sort_by { |r| r.name }.map do |request|
spec = request.spec
name = request.name
requirement = request.request.dependency.requirement
requirement_string =
if [Gem::Resolver::VendorSpecification,
Gem::Resolver::GitSpecification].include? spec.class then
"!"
else
requirement.for_lockfile
end
[name, requirement_string]
end
end
dependencies = dependencies.map do |name, requirement_string|
" #{name}#{requirement_string}"
end
out.concat dependencies
out.concat @dependencies.sort_by { |name,| name }.map { |name, requirement|
" #{name}#{requirement.for_lockfile}"
}
out << nil
end
@ -207,8 +200,6 @@ class Gem::RequestSet::Lockfile
# The contents of the lock file.
def to_s
@set.resolve
out = []
groups = spec_groups

Просмотреть файл

@ -23,6 +23,8 @@ class Gem::Requirement
"~>" => lambda { |v, r| v >= r && v.release < r.bump }
}
SOURCE_SET_REQUIREMENT = Struct.new(:for_lockfile).new "!" # :nodoc:
quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*" # :nodoc:
@ -54,6 +56,8 @@ class Gem::Requirement
input
when Gem::Version, Array then
new input
when '!' then
source_set
else
if input.respond_to? :to_str then
new [input.to_str]
@ -70,6 +74,13 @@ class Gem::Requirement
new '>= 0'
end
###
# A source set requirement, used for Gemfiles and lockfiles
def self.source_set # :nodoc:
SOURCE_SET_REQUIREMENT
end
##
# Parse +obj+, returning an <tt>[op, version]</tt> pair. +obj+ can
# be a String or a Gem::Version.

Просмотреть файл

@ -383,6 +383,8 @@ class Gem::Specification < Gem::BasicSpecification
attr_reader :description
##
# :category: Recommended gemspec attributes
#
# A contact email address (or addresses) for this gem
#
# Usage:
@ -393,11 +395,13 @@ class Gem::Specification < Gem::BasicSpecification
attr_accessor :email
##
# :category: Recommended gemspec attributes
#
# The URL of this gem's home page
#
# Usage:
#
# spec.homepage = 'http://rake.rubyforge.org'
# spec.homepage = 'https://github.com/ruby/rake'
attr_accessor :homepage
@ -1321,6 +1325,50 @@ class Gem::Specification < Gem::BasicSpecification
unresolved.delete self.name
end
##
# Abbreviate the spec for downloading. Abbreviated specs are only used for
# searching, downloading and related activities and do not need deployment
# specific information (e.g. list of files). So we abbreviate the spec,
# making it much smaller for quicker downloads.
def abbreviate
self.files = []
self.test_files = []
self.rdoc_options = []
self.extra_rdoc_files = []
self.cert_chain = []
end
##
# Sanitize the descriptive fields in the spec. Sometimes non-ASCII
# characters will garble the site index. Non-ASCII characters will
# be replaced by their XML entity equivalent.
def sanitize
self.summary = sanitize_string(summary)
self.description = sanitize_string(description)
self.post_install_message = sanitize_string(post_install_message)
self.authors = authors.collect { |a| sanitize_string(a) }
end
##
# Sanitize a single string.
def sanitize_string(string)
return string unless string
# HACK the #to_s is in here because RSpec has an Array of Arrays of
# Strings for authors. Need a way to disallow bad values on gemspec
# generation. (Probably won't happen.)
string = string.to_s
begin
Builder::XChar.encode string
rescue NameError, NoMethodError
string.to_xs
end
end
##
# Returns an array with bindir attached to each executable in the
# +executables+ list
@ -2609,7 +2657,7 @@ http://opensource.org/licenses/alphabetical
# Warnings
%w[author description email homepage summary].each do |attribute|
%w[author email homepage summary].each do |attribute|
value = self.send attribute
warning "no #{attribute} specified" if value.nil? or value.empty?
end

Просмотреть файл

@ -1426,6 +1426,21 @@ Also, a list:
end
# require dependencies that are not discoverable once GEM_HOME and GEM_PATH
# are wiped
begin
gem 'rake'
rescue Gem::LoadError
end
require 'rake/packagetask'
begin
gem 'rdoc'
require 'rdoc'
rescue LoadError, Gem::LoadError
end
require 'rubygems/test_utilities'
ENV['GEM_HOME'] = Dir.mktmpdir "home"
ENV['GEM_PATH'] = Dir.mktmpdir "path"

Просмотреть файл

@ -43,11 +43,9 @@ module Gem::Text
t = str2
n = s.length
m = t.length
max = n/2
return m if (0 == n)
return n if (0 == m)
return n if (n - m).abs > max
d = (0..m).to_a
x = nil

Просмотреть файл

@ -217,12 +217,14 @@ class Gem::Version
# Pre-release (alpha) parts, e.g, 5.3.1.b.2 => 5.4, are ignored.
def bump
segments = self.segments.dup
segments.pop while segments.any? { |s| String === s }
segments.pop if segments.size > 1
@bump ||= begin
segments = self.segments.dup
segments.pop while segments.any? { |s| String === s }
segments.pop if segments.size > 1
segments[-1] = segments[-1].succ
self.class.new segments.join(".")
segments[-1] = segments[-1].succ
self.class.new segments.join(".")
end
end
##
@ -291,11 +293,13 @@ class Gem::Version
# Non-prerelease versions return themselves.
def release
return self unless prerelease?
segments = self.segments.dup
segments.pop while segments.any? { |s| String === s }
self.class.new segments.join('.')
@release ||= if prerelease?
segments = self.segments.dup
segments.pop while segments.any? { |s| String === s }
self.class.new segments.join('.')
else
self
end
end
def segments # :nodoc:

Просмотреть файл

@ -225,6 +225,28 @@ class TestGemCommandsPristineCommand < Gem::TestCase
assert_empty out, out.inspect
end
def test_skip
a = util_spec 'a'
b = util_spec 'b'
install_gem a
install_gem b
@cmd.options[:args] = %w[a b]
@cmd.options[:skip] = 'a'
use_ui @ui do
@cmd.execute
end
out = @ui.output.split "\n"
assert_equal "Restoring gems to pristine condition...", out.shift
assert_equal "Skipped #{a.full_name}, it was given through options", out.shift
assert_equal "Restored #{b.full_name}", out.shift
assert_empty out, out.inspect
end
def test_execute_many_multi_repo
a = util_spec 'a'
install_gem a

Просмотреть файл

@ -88,7 +88,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[a], @gda.requires['a']
expected = { 'a' => nil }
expected = { 'a' => Gem::Requirement.default }
assert_equal expected, @gda.dependencies
end
@ -112,7 +112,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[git/a master], @git_set.repositories['a']
expected = { 'a' => '!' }
expected = { 'a' => Gem::Requirement.create('!') }
assert_equal expected, @gda.dependencies
end
@ -125,7 +125,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[https://example@bitbucket.org/example/repository.git master],
@git_set.repositories['a']
expected = { 'a' => '!' }
expected = { 'a' => Gem::Requirement.create('!') }
assert_equal expected, @gda.dependencies
end
@ -138,7 +138,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[https://example@bitbucket.org/example/example.git master],
@git_set.repositories['a']
expected = { 'a' => '!' }
expected = { 'a' => Gem::Requirement.create('!') }
assert_equal expected, @gda.dependencies
end
@ -193,7 +193,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[git://github.com/example/repository.git master],
@git_set.repositories['a']
expected = { 'a' => '!' }
expected = { 'a' => Gem::Requirement.create('!') }
assert_equal expected, @gda.dependencies
end
@ -206,7 +206,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[git://github.com/example/example.git master],
@git_set.repositories['a']
expected = { 'a' => '!' }
expected = { 'a' => Gem::Requirement.create('!') }
assert_equal expected, @gda.dependencies
end
@ -224,7 +224,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_empty @set.dependencies
expected = { 'a' => nil }
expected = { 'a' => Gem::Requirement.default }
assert_equal expected, @gda.dependencies
end
@ -246,7 +246,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal "#{name}-#{version}", loaded.full_name
expected = { name => '!' }
expected = { name => Gem::Requirement.create('!') }
assert_equal expected, @gda.dependencies
end
@ -405,7 +405,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal [dep('a', '~> 1.0')], @set.dependencies
expected = { 'a' => ['~> 1.0'] }
expected = { 'a' => Gem::Requirement.create(['~> 1.0']) }
assert_equal expected, @gda.dependencies
end
@ -415,7 +415,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal [dep('b', '~> 1.0', '>= 1.0.2')], @set.dependencies
expected = { 'b' => ['~> 1.0', '>= 1.0.2'] }
expected = { 'b' => Gem::Requirement.create(['~> 1.0', '>= 1.0.2']) }
assert_equal expected, @gda.dependencies
end
@ -485,7 +485,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
assert_equal %w[a], @gda.requires['a']
expected = {
'a' => '!',
'a' => Gem::Requirement.create('!'),
'b' => req('= 2'),
'c' => req('= 3'),
}

Просмотреть файл

@ -21,7 +21,10 @@ class TestGemRequestSetLockfile < Gem::TestCase
@gem_deps_file = 'gem.deps.rb'
@lockfile = Gem::RequestSet::Lockfile.new @set, @gem_deps_file
end
def lockfile
Gem::RequestSet::Lockfile.build @set, @gem_deps_file
end
def write_lockfile lockfile
@ -44,7 +47,7 @@ class TestGemRequestSetLockfile < Gem::TestCase
out = []
@lockfile.add_DEPENDENCIES out
lockfile.add_DEPENDENCIES out
expected = [
'DEPENDENCIES',
@ -62,7 +65,7 @@ class TestGemRequestSetLockfile < Gem::TestCase
end
end
dependencies = { 'a' => '~> 2.0' }
dependencies = { 'a' => Gem::Requirement.new('~> 2.0') }
@set.gem 'a'
@set.resolve
@ -100,7 +103,7 @@ class TestGemRequestSetLockfile < Gem::TestCase
out = []
@lockfile.add_GEM out, @lockfile.spec_groups
lockfile.add_GEM out, lockfile.spec_groups
expected = [
'GEM',
@ -131,7 +134,7 @@ class TestGemRequestSetLockfile < Gem::TestCase
out = []
@lockfile.add_PLATFORMS out
lockfile.add_PLATFORMS out
expected = [
'PLATFORMS',
@ -144,11 +147,11 @@ class TestGemRequestSetLockfile < Gem::TestCase
end
def test_relative_path_from
path = @lockfile.relative_path_from '/foo', '/foo/bar'
path = lockfile.relative_path_from '/foo', '/foo/bar'
assert_equal File.expand_path('/foo'), path
path = @lockfile.relative_path_from '/foo', '/foo'
path = lockfile.relative_path_from '/foo', '/foo'
assert_equal '.', path
end
@ -173,7 +176,7 @@ DEPENDENCIES
a
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_to_s_gem_dependency
@ -204,7 +207,7 @@ DEPENDENCIES
c
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_to_s_gem_dependency_non_default
@ -232,7 +235,7 @@ DEPENDENCIES
b
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_to_s_gem_dependency_requirement
@ -259,7 +262,7 @@ DEPENDENCIES
b
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_to_s_gem_path
@ -282,7 +285,7 @@ DEPENDENCIES
a!
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_to_s_gem_path_absolute
@ -305,7 +308,7 @@ DEPENDENCIES
a!
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_to_s_gem_platform
@ -330,7 +333,7 @@ DEPENDENCIES
a
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_to_s_gem_source
@ -368,7 +371,7 @@ DEPENDENCIES
b
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_to_s_git
@ -435,11 +438,11 @@ DEPENDENCIES
c!
LOCKFILE
assert_equal expected, @lockfile.to_s
assert_equal expected, lockfile.to_s
end
def test_write
@lockfile.write
lockfile.write
gem_deps_lock_file = "#{@gem_deps_file}.lock"
@ -458,7 +461,7 @@ DEPENDENCIES
end
assert_raises Gem::UnsatisfiableDependencyError do
@lockfile.write
lockfile.write
end
assert_path_exists gem_deps_lock_file

Просмотреть файл

@ -2413,8 +2413,6 @@ duplicate dependency on b (>= 1.2.3), (~> 1.2) use:
@a1.validate
end
assert_match "#{w}: no description specified\n", @ui.error, "error"
@ui = Gem::MockGemUi.new
@a1.summary = "this is my summary"
@a1.description = @a1.summary

Просмотреть файл

@ -64,6 +64,8 @@ Without the wrapping, the text might not look good in the RSS feed.
def test_levenshtein_distance_remove
assert_equal 3, levenshtein_distance("zentest", "zentestxxx")
assert_equal 3, levenshtein_distance("zentestxxx", "zentest")
assert_equal 13, levenshtein_distance("cat", "thundercatsarego")
assert_equal 13, levenshtein_distance("thundercatsarego", "cat")
end
def test_levenshtein_distance_replace