summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-01 08:30:21 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-01 08:30:21 +0000
commitcec4f5a9e02751404fd1408b6d81078f409b750d (patch)
treee0269284018921fa6a8c32dc007c819075d50cfd
parentffe920d674857087037327dc4075cd0c7e8e9fd1 (diff)
* lib/rubygems: Update to RubyGems 2.4.2.
* test/rubygems: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/update_command.rb5
-rw-r--r--lib/rubygems/installer.rb6
-rw-r--r--lib/rubygems/request_set.rb42
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb9
-rw-r--r--lib/rubygems/request_set/lockfile.rb8
-rw-r--r--lib/rubygems/source/git.rb10
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb13
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb19
-rw-r--r--test/rubygems/test_gem_request_set_lockfile.rb10
-rw-r--r--test/rubygems/test_gem_source_git.rb11
12 files changed, 127 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 147d975c250..7fe36ebb23a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Oct 1 17:28:58 2014 Eric Hodel <drbrain@segment7.net>
+
+ * lib/rubygems: Update to RubyGems 2.4.2.
+ * test/rubygems: ditto.
+
Tue Sep 30 22:25:32 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parser_data_type): separate ripper data type for from
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 453520665ae..ac22c3cdcec 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -9,7 +9,7 @@ require 'rbconfig'
require 'thread'
module Gem
- VERSION = '2.4.1'
+ VERSION = '2.4.2'
end
# Must be first since it unloads the prelude from 1.9.2
diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 9e9bd088f2d..b1320896120 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -203,7 +203,10 @@ command to remove old versions.
def update_gem name, version = Gem::Requirement.default
return if @updated.any? { |spec| spec.name == name }
- @installer ||= Gem::DependencyInstaller.new options
+ update_options = options.dup
+ update_options[:prerelease] = version.prerelease?
+
+ @installer = Gem::DependencyInstaller.new update_options
say "Updating #{name}"
begin
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index e5cfc0f536a..d497ba5c056 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -681,14 +681,14 @@ TEXT
# return the stub script text used to launch the true Ruby script
def windows_stub_script(bindir, bin_file_name)
- ruby = File.basename(Gem.ruby).chomp('"')
+ ruby = Gem.ruby.chomp('"').tr(File::SEPARATOR, "\\")
return <<-TEXT
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
-@"#{bindir.tr(File::SEPARATOR, File::ALT_SEPARATOR)}\\#{ruby}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
+@"#{ruby}" "#{File.join(bindir, bin_file_name)}" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
-@"%~dp0#{ruby}" "%~dpn0" %*
+@"#{ruby}" "%~dpn0" %*
TEXT
end
diff --git a/lib/rubygems/request_set.rb b/lib/rubygems/request_set.rb
index d12e06358d2..57f9c39ba9d 100644
--- a/lib/rubygems/request_set.rb
+++ b/lib/rubygems/request_set.rb
@@ -284,6 +284,48 @@ class Gem::RequestSet
gf.load
end
+ def pretty_print q # :nodoc:
+ q.group 2, '[RequestSet:', ']' do
+ q.breakable
+
+ if @remote then
+ q.text 'remote'
+ q.breakable
+ end
+
+ if @prerelease then
+ q.text 'prerelease'
+ q.breakable
+ end
+
+ if @development_shallow then
+ q.text 'shallow development'
+ q.breakable
+ elsif @development then
+ q.text 'development'
+ q.breakable
+ end
+
+ if @soft_missing then
+ q.text 'soft missing'
+ end
+
+ q.group 2, '[dependencies:', ']' do
+ q.breakable
+ @dependencies.map do |dep|
+ q.text dep.to_s
+ q.breakable
+ end
+ end
+
+ q.breakable
+ q.text 'sets:'
+
+ q.breakable
+ q.pp @sets.map { |set| set.class }
+ end
+ end
+
##
# Resolve the requested dependencies and return an Array of Specification
# objects to be activated.
diff --git a/lib/rubygems/request_set/gem_dependency_api.rb b/lib/rubygems/request_set/gem_dependency_api.rb
index 24179dd1ed7..9aad5ab5d37 100644
--- a/lib/rubygems/request_set/gem_dependency_api.rb
+++ b/lib/rubygems/request_set/gem_dependency_api.rb
@@ -596,8 +596,17 @@ Gem dependencies file #{@path} requires #{name} more than once.
groups = gem_group spec.name, {}
+ self_dep = Gem::Dependency.new spec.name, spec.version
+
+ add_dependencies groups, [self_dep]
add_dependencies groups, spec.runtime_dependencies
+ @dependencies[spec.name] = '!'
+
+ spec.dependencies.each do |dep|
+ @dependencies[dep.name] = dep.requirement
+ end
+
groups << development_group
add_dependencies groups, spec.development_dependencies
diff --git a/lib/rubygems/request_set/lockfile.rb b/lib/rubygems/request_set/lockfile.rb
index 2901dba871a..918aa971e59 100644
--- a/lib/rubygems/request_set/lockfile.rb
+++ b/lib/rubygems/request_set/lockfile.rb
@@ -168,8 +168,12 @@ class Gem::RequestSet::Lockfile
dest = File.expand_path(dest)
base = File.expand_path(base)
- if dest.index(base) == 0
- return dest[base.size+1..-1]
+ if dest.index(base) == 0 then
+ offset = dest[base.size+1..-1]
+
+ return '.' unless offset
+
+ offset
else
dest
end
diff --git a/lib/rubygems/source/git.rb b/lib/rubygems/source/git.rb
index fb9cbce2fbb..35c2270a744 100644
--- a/lib/rubygems/source/git.rb
+++ b/lib/rubygems/source/git.rb
@@ -178,9 +178,17 @@ class Gem::Source::Git < Gem::Source
# Converts the git reference for the repository into a commit hash.
def rev_parse # :nodoc:
+ hash = nil
+
Dir.chdir repo_cache_dir do
- Gem::Util.popen(@git, 'rev-parse', @reference).strip
+ hash = Gem::Util.popen(@git, 'rev-parse', @reference).strip
end
+
+ raise Gem::Exception,
+ "unable to find reference #{@reference} in #{@repository}" unless
+ $?.success?
+
+ hash
end
##
diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
index 2b3bb568550..6a327068e25 100644
--- a/test/rubygems/test_gem_commands_update_command.rb
+++ b/test/rubygems/test_gem_commands_update_command.rb
@@ -485,6 +485,19 @@ class TestGemCommandsUpdateCommand < Gem::TestCase
assert_equal expected, @cmd.options
end
+ def test_update_gem_prerelease
+ spec_fetcher do |fetcher|
+ fetcher.spec 'a', '1.a'
+ fetcher.gem 'a', '1.b'
+ end
+
+ @cmd.update_gem 'a', Gem::Requirement.new('= 1.b')
+
+ refute_empty @cmd.updated
+
+ assert @cmd.installer.instance_variable_get :@prerelease
+ end
+
def test_update_gem_unresolved_dependency
spec_fetcher do |fetcher|
fetcher.spec 'a', 1
diff --git a/test/rubygems/test_gem_request_set_gem_dependency_api.rb b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
index c2bf5ff3789..65b30f83bf5 100644
--- a/test/rubygems/test_gem_request_set_gem_dependency_api.rb
+++ b/test/rubygems/test_gem_request_set_gem_dependency_api.rb
@@ -460,9 +460,18 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@gda.gemspec
- assert_equal [dep('b', '= 2'), dep('c', '=3')], @set.dependencies
+ assert_equal [dep('a', '= 1'), dep('b', '= 2'), dep('c', '=3')],
+ @set.dependencies
assert_equal %w[a], @gda.requires['a']
+
+ expected = {
+ 'a' => '!',
+ 'b' => req('= 2'),
+ 'c' => req('= 3'),
+ }
+
+ assert_equal expected, @gda.dependencies
end
def test_gemspec_bad
@@ -489,7 +498,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@gda.gemspec :development_group => :other
- assert_equal [dep('b', '= 2')], @set.dependencies
+ assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies
assert_equal %w[a], @gda.requires['a']
end
@@ -525,7 +534,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@gda.gemspec :name => 'b'
- assert_equal [dep('c', '= 3')], @set.dependencies
+ assert_equal [dep('b', '= 2'), dep('c', '= 3')], @set.dependencies
end
def test_gemspec_named
@@ -537,7 +546,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@gda.gemspec
- assert_equal [dep('b', '= 2')], @set.dependencies
+ assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies
end
def test_gemspec_none
@@ -559,7 +568,7 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
@gda.gemspec :path => 'other'
- assert_equal [dep('b', '= 2')], @set.dependencies
+ assert_equal [dep('a', '= 1'), dep('b', '= 2')], @set.dependencies
end
def test_git
diff --git a/test/rubygems/test_gem_request_set_lockfile.rb b/test/rubygems/test_gem_request_set_lockfile.rb
index 96cc12e1641..6b6c727459b 100644
--- a/test/rubygems/test_gem_request_set_lockfile.rb
+++ b/test/rubygems/test_gem_request_set_lockfile.rb
@@ -643,6 +643,16 @@ DEPENDENCIES
assert_equal [:EOF], @lockfile.peek
end
+ def test_relative_path_from
+ path = @lockfile.relative_path_from '/foo', '/foo/bar'
+
+ assert_equal '/foo', path
+
+ path = @lockfile.relative_path_from '/foo', '/foo'
+
+ assert_equal '.', path
+ end
+
def test_skip
tokens = [[:token]]
diff --git a/test/rubygems/test_gem_source_git.rb b/test/rubygems/test_gem_source_git.rb
index cf5f088c034..4b1c65a51b9 100644
--- a/test/rubygems/test_gem_source_git.rb
+++ b/test/rubygems/test_gem_source_git.rb
@@ -180,6 +180,17 @@ class TestGemSourceGit < Gem::TestCase
source.cache
refute_equal master_head, source.rev_parse
+
+ source = Gem::Source::Git.new @name, @repository, 'nonexistent', false
+
+ source.cache
+
+ e = assert_raises Gem::Exception do
+ source.rev_parse
+ end
+
+ assert_equal "unable to find reference nonexistent in #{@repository}",
+ e.message
end
def test_root_dir