diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-11-01 23:45:48 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-02-21 06:39:36 +0000 |
| commit | c8fb4f308bc24c75c2713129a0972ffcd8742b3f (patch) | |
| tree | 39c2c9813eff4ef0ebb84efeb7aa52e9a33d6bac /lib | |
| parent | d578684989fd2d75f086a259719e3eb0fe57ccb2 (diff) | |
[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.
https://github.com/rubygems/rubygems/commit/74b4db8d30
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rubygems/psych_tree.rb | 4 | ||||
| -rw-r--r-- | lib/rubygems/specification.rb | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/rubygems/psych_tree.rb b/lib/rubygems/psych_tree.rb index 2d478c94d9..7d17fc29cf 100644 --- a/lib/rubygems/psych_tree.rb +++ b/lib/rubygems/psych_tree.rb @@ -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 diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 61ea3fcfdc..29139cf725 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -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 |
