[rubygems/rubygems] Remove Gem::Specification#mark_version
This gets in the middle if we ever start allowing to build as if using a different RubyGems version than the one being run. This could be useful to make `gem rebuild` a little more usable, and it's already done by Bundler specs which already make this method a noop when they need this. I'm not sure forcefully setting this, even if user explicitly specified something else is helpful. Since this could potentially prevent gems explicitly setting a constant RubyGems version from building, I changed the error of incorrect RubyGems version from a hard error to a warning, since it will start happening in those cases if we stop overwriting the version. https://github.com/rubygems/rubygems/commit/45676af80d
This commit is contained in:
parent
0948b6a592
commit
281df1e495
@ -294,7 +294,6 @@ class Gem::Package
|
|||||||
|
|
||||||
Gem.load_yaml
|
Gem.load_yaml
|
||||||
|
|
||||||
@spec.mark_version
|
|
||||||
@spec.validate true, strict_validation unless skip_validation
|
@spec.validate true, strict_validation unless skip_validation
|
||||||
|
|
||||||
setup_signer(
|
setup_signer(
|
||||||
|
@ -194,7 +194,7 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
NOT_FOUND = Struct.new(:to_spec, :this).new # :nodoc:
|
NOT_FOUND = Struct.new(:to_spec, :this).new # :nodoc:
|
||||||
|
|
||||||
# Tracking removed method calls to warn users during build time.
|
# Tracking removed method calls to warn users during build time.
|
||||||
REMOVED_METHODS = [:rubyforge_project=].freeze # :nodoc:
|
REMOVED_METHODS = [:rubyforge_project=, :mark_version].freeze # :nodoc:
|
||||||
def removed_method_calls
|
def removed_method_calls
|
||||||
@removed_method_calls ||= []
|
@removed_method_calls ||= []
|
||||||
end
|
end
|
||||||
@ -1874,8 +1874,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
end
|
end
|
||||||
|
|
||||||
def encode_with(coder) # :nodoc:
|
def encode_with(coder) # :nodoc:
|
||||||
mark_version
|
|
||||||
|
|
||||||
coder.add "name", @name
|
coder.add "name", @name
|
||||||
coder.add "version", @version
|
coder.add "version", @version
|
||||||
platform = case @original_platform
|
platform = case @original_platform
|
||||||
@ -2170,13 +2168,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
@spec_file = nil
|
@spec_file = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
|
||||||
# Sets the rubygems_version to the current RubyGems version.
|
|
||||||
|
|
||||||
def mark_version
|
|
||||||
@rubygems_version = Gem::VERSION
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Track removed method calls to warn about during build time.
|
# Track removed method calls to warn about during build time.
|
||||||
# Warn about unknown attributes while loading a spec.
|
# Warn about unknown attributes while loading a spec.
|
||||||
@ -2494,7 +2485,6 @@ class Gem::Specification < Gem::BasicSpecification
|
|||||||
# still have their default values are omitted.
|
# still have their default values are omitted.
|
||||||
|
|
||||||
def to_ruby
|
def to_ruby
|
||||||
mark_version
|
|
||||||
result = []
|
result = []
|
||||||
result << "# -*- encoding: utf-8 -*-"
|
result << "# -*- encoding: utf-8 -*-"
|
||||||
result << "#{Gem::StubSpecification::PREFIX}#{name} #{version} #{platform} #{raw_require_paths.join("\0")}"
|
result << "#{Gem::StubSpecification::PREFIX}#{name} #{version} #{platform} #{raw_require_paths.join("\0")}"
|
||||||
|
@ -274,7 +274,9 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
|
|||||||
|
|
||||||
return if rubygems_version == Gem::VERSION
|
return if rubygems_version == Gem::VERSION
|
||||||
|
|
||||||
error "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
|
warning "expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
|
||||||
|
|
||||||
|
@specification.rubygems_version = Gem::VERSION
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_required_attributes
|
def validate_required_attributes
|
||||||
|
@ -518,7 +518,6 @@ module Spec
|
|||||||
|
|
||||||
if options[:rubygems_version]
|
if options[:rubygems_version]
|
||||||
@spec.rubygems_version = options[:rubygems_version]
|
@spec.rubygems_version = options[:rubygems_version]
|
||||||
def @spec.mark_version; end
|
|
||||||
|
|
||||||
def @spec.validate(*); end
|
def @spec.validate(*); end
|
||||||
end
|
end
|
||||||
|
@ -1281,7 +1281,6 @@ class TestGem < Gem::TestCase
|
|||||||
def test_self_try_activate_missing_extensions
|
def test_self_try_activate_missing_extensions
|
||||||
spec = util_spec "ext", "1" do |s|
|
spec = util_spec "ext", "1" do |s|
|
||||||
s.extensions = %w[ext/extconf.rb]
|
s.extensions = %w[ext/extconf.rb]
|
||||||
s.mark_version
|
|
||||||
s.installed_by_version = v("2.2")
|
s.installed_by_version = v("2.2")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ end
|
|||||||
s.add_dependency "jabber4r", "> 0.0.0"
|
s.add_dependency "jabber4r", "> 0.0.0"
|
||||||
s.add_dependency "pqa", ["> 0.4", "<= 0.6"]
|
s.add_dependency "pqa", ["> 0.4", "<= 0.6"]
|
||||||
|
|
||||||
s.mark_version
|
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -69,7 +68,6 @@ end
|
|||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
s.platform = platform
|
s.platform = platform
|
||||||
|
|
||||||
s.mark_version
|
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
s.installed_by_version = v("2.2")
|
s.installed_by_version = v("2.2")
|
||||||
end
|
end
|
||||||
@ -96,7 +94,6 @@ end
|
|||||||
s.requirements << "A working computer"
|
s.requirements << "A working computer"
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
|
|
||||||
s.mark_version
|
|
||||||
s.files = %w[lib/code.rb]
|
s.files = %w[lib/code.rb]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3187,7 +3184,7 @@ or set it to nil if you don't want to specify a license.
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_removed_methods
|
def test_removed_methods
|
||||||
assert_equal Gem::Specification::REMOVED_METHODS, [:rubyforge_project=]
|
assert_equal Gem::Specification::REMOVED_METHODS, [:rubyforge_project=, :mark_version]
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validate_removed_rubyforge_project
|
def test_validate_removed_rubyforge_project
|
||||||
@ -3480,12 +3477,17 @@ Did you mean 'Ruby'?
|
|||||||
util_setup_validate
|
util_setup_validate
|
||||||
|
|
||||||
@a1.rubygems_version = "3"
|
@a1.rubygems_version = "3"
|
||||||
e = assert_raise Gem::InvalidSpecificationException do
|
|
||||||
|
use_ui @ui do
|
||||||
@a1.validate
|
@a1.validate
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_equal "expected RubyGems version #{Gem::VERSION}, was 3",
|
expected = <<~EXPECTED
|
||||||
e.message
|
#{w}: expected RubyGems version #{Gem::VERSION}, was 3
|
||||||
|
#{w}: See https://guides.rubygems.org/specification-reference/ for help
|
||||||
|
EXPECTED
|
||||||
|
|
||||||
|
assert_equal expected, @ui.error
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_validate_specification_version
|
def test_validate_specification_version
|
||||||
|
Loading…
x
Reference in New Issue
Block a user