mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[rubygems/rubygems] Skip nil-value keys to make metadata reproducible
Nil-value keys in a mapping end with a space or not depending on
libyaml versions, and result metadata are different per platforms.
This commit makes to skip such keys to make metadata reproducible
accross platforms.
74b4db8d30
This commit is contained in:
parent
d578684989
commit
c8fb4f308b
3 changed files with 26 additions and 1 deletions
|
@ -14,6 +14,10 @@ module Gem
|
|||
@emitter.scalar str, nil, nil, false, true, quote
|
||||
end
|
||||
|
||||
def visit_Hash(o)
|
||||
super(o.dup.delete_if {|_, v| v.nil? })
|
||||
end
|
||||
|
||||
# Noop this out so there are no anchors
|
||||
def register(target, obj)
|
||||
end
|
||||
|
|
|
@ -1890,7 +1890,8 @@ class Gem::Specification < Gem::BasicSpecification
|
|||
|
||||
attributes = @@attributes.map(&:to_s) - %w[name version platform]
|
||||
attributes.each do |name|
|
||||
coder.add name, instance_variable_get("@#{name}")
|
||||
value = instance_variable_get("@#{name}")
|
||||
coder.add name, value unless value.nil?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2517,6 +2517,26 @@ end
|
|||
assert_match(/^platform: ruby$/, @a1.to_yaml)
|
||||
end
|
||||
|
||||
def test_to_yaml_no_autorequire
|
||||
yaml_str = @a1.to_yaml
|
||||
|
||||
refute_match(/^autorequire:/, yaml_str)
|
||||
end
|
||||
|
||||
def test_to_yaml_no_signing_key
|
||||
@a1.signing_key = nil
|
||||
yaml_str = @a1.to_yaml
|
||||
|
||||
refute_match(/^signing_key:/, yaml_str)
|
||||
end
|
||||
|
||||
def test_to_yaml_no_post_install_message
|
||||
@a1.post_install_message = nil
|
||||
yaml_str = @a1.to_yaml
|
||||
|
||||
refute_match(/^post_install_message:/, yaml_str)
|
||||
end
|
||||
|
||||
def test_validate
|
||||
util_setup_validate
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue