diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-12 05:07:50 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-12 05:07:50 +0000 |
commit | 7f9bf068fcff9ca7d6a21711f31c5b8d6022dddf (patch) | |
tree | 2bf9d83db081c73e583aeaf9f30140732c43282a /lib/rubygems/specification_policy.rb | |
parent | 53a5b276b8bc6e22a9fecc23dd99259e2d0e7fa4 (diff) | |
download | ruby-7f9bf068fcff9ca7d6a21711f31c5b8d6022dddf.tar.gz |
Merge rubygems@21f12a8 from upstream.
* [BudlerVersionFinder] set .filter! and .compatible? to match only on major versions https://github.com/rubygems/rubygems/pull/2515
* Fix broken symlink that points to ../* https://github.com/rubygems/rubygems/pull/2516
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/specification_policy.rb')
-rw-r--r-- | lib/rubygems/specification_policy.rb | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb index bc552f8287..4b79c1ac61 100644 --- a/lib/rubygems/specification_policy.rb +++ b/lib/rubygems/specification_policy.rb @@ -150,19 +150,24 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use: if open_ended op, dep_version = dep.requirement.requirements.first - base = dep_version.segments.first 2 - - bugfix = if op == '>' - ", '> #{dep_version}'" - elsif op == '>=' and base != dep_version.segments - ", '>= #{dep_version}'" - end - - warning_messages << <<-WARNING -open-ended dependency on #{dep} is not recommended - if #{dep.name} is semantically versioned, use: - add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix} - WARNING + segments = dep_version.segments + + base = segments.first 2 + + recommendation = if (op == '>' || op == '>=') && segments == [0] + " use a bounded requirement, such as '~> x.y'" + else + bugfix = if op == '>' + ", '> #{dep_version}'" + elsif op == '>=' and base != segments + ", '>= #{dep_version}'" + end + + " if #{dep.name} is semantically versioned, use:\n" \ + " add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}" + end + + warning_messages << ["open-ended dependency on #{dep} is not recommended", recommendation].join("\n") + "\n" end end if error_messages.any? |