ruby-changes:62454
From: bronzdoc <ko1@a...>
Date: Fri, 31 Jul 2020 21:08:24 +0900 (JST)
Subject: [ruby-changes:62454] 00bdac18cf (master): [rubygems/rubygems] Warn on duplicate dependency in a specification
https://git.ruby-lang.org/ruby.git/commit/?id=00bdac18cf From 00bdac18cffce3fb74aa596c828a09e7d52affcd Mon Sep 17 00:00:00 2001 From: bronzdoc <lsagastume1990@g...> Date: Tue, 28 Jul 2020 22:15:09 -0600 Subject: [rubygems/rubygems] Warn on duplicate dependency in a specification https://github.com/rubygems/rubygems/commit/af3e5f7883 diff --git a/lib/rubygems/specification.rb b/lib/rubygems/specification.rb index 5e326e0..d3d6d9c 100644 --- a/lib/rubygems/specification.rb +++ b/lib/rubygems/specification.rb @@ -556,6 +556,10 @@ class Gem::Specification < Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L556 # spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4' def add_runtime_dependency(gem, *requirements) + if requirements.uniq.size != requirements.size + warn "WARNING: duplicate dependency #{requirements}" + end + add_dependency_with_type(gem, :runtime, requirements) end diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index c4da823..cd00f74 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -3051,6 +3051,13 @@ Please report a bug if this causes problems. https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L3051 end end + def test_duplicate_runtime_dependency + expected = "WARNING: duplicate dependency [\"~> 3.0\", \"~> 3.0\"]\n" + assert_output nil, expected do + @a1.add_runtime_dependency "b", "~> 3.0", "~> 3.0" + end + end + def set_orig(cls) s_cls = cls.singleton_class s_cls.send :alias_method, :orig_unresolved_deps , :unresolved_deps -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/