From de025f8dd1cc08752fca1dfeb8c6f507e5c79c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Wed, 21 Mar 2018 16:14:17 -0300 Subject: [PATCH] Add a note for the non-semantically versioned case --- lib/rubygems/specification_policy.rb | 4 ++++ test/rubygems/test_gem_specification.rb | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb index 039f8474b958..c076881915d7 100644 --- a/lib/rubygems/specification_policy.rb +++ b/lib/rubygems/specification_policy.rb @@ -144,11 +144,15 @@ def validate_dependencies # :nodoc: _, dep_version = dep.requirement.requirements.first base = dep_version.segments.first 2 + upper_bound = dep_version.segments.first(dep_version.segments.length - 1) + upper_bound[-1] += 1 warning_messages << <<-WARNING pessimistic dependency on #{dep} may be overly strict if #{dep.name} is semantically versioned, use: add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}', '>= #{dep_version}' + if #{dep.name} is not semantically versioned, you can bypass this warning with: + add_#{dep.type}_dependency '#{dep.name}', '>= #{dep_version}', '< #{upper_bound.join '.'}' WARNING end diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 1e3e06c05500..457f868773e2 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -2622,9 +2622,13 @@ def test_validate_dependencies #{w}: pessimistic dependency on d (~> 1.2.3) may be overly strict if d is semantically versioned, use: add_runtime_dependency 'd', '~> 1.2', '>= 1.2.3' + if d is not semantically versioned, you can bypass this warning with: + add_runtime_dependency 'd', '>= 1.2.3', '< 1.3' #{w}: pessimistic dependency on e (~> 1.2.3.4) may be overly strict if e is semantically versioned, use: add_runtime_dependency 'e', '~> 1.2', '>= 1.2.3.4' + if e is not semantically versioned, you can bypass this warning with: + add_runtime_dependency 'e', '>= 1.2.3.4', '< 1.2.4' #{w}: open-ended dependency on i (>= 1.2) is not recommended if i is semantically versioned, use: add_runtime_dependency 'i', '~> 1.2' @@ -2640,6 +2644,8 @@ def test_validate_dependencies #{w}: pessimistic dependency on m (~> 2.1.0) may be overly strict if m is semantically versioned, use: add_runtime_dependency 'm', '~> 2.1', '>= 2.1.0' + if m is not semantically versioned, you can bypass this warning with: + add_runtime_dependency 'm', '>= 2.1.0', '< 2.2' #{w}: See http://guides.rubygems.org/specification-reference/ for help EXPECTED