summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDrew Stevenson <drew@soona.co>2023-11-30 22:35:33 -0600
committergit <svn-admin@ruby-lang.org>2023-12-14 00:06:05 +0000
commitbeefce1444adafac484bb69b625de2b30e7e80d2 (patch)
tree5c3318fecd5ba177253e24ffa62446fd23a1a4e3 /lib
parentd7dad644658697a05949b66e736a34fb772771de (diff)
[rubygems/rubygems] Warn for duplicate meta data links
Match order of METADATA_LINK_KEYS to order used by rubygems.org in Links model. Add missing download_uri key. https://github.com/rubygems/rubygems/commit/d2922cd6e9
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/specification_policy.rb27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
index ca5fa5fb72..6655825287 100644
--- a/lib/rubygems/specification_policy.rb
+++ b/lib/rubygems/specification_policy.rb
@@ -12,13 +12,14 @@ class Gem::SpecificationPolicy
VALID_URI_PATTERN = %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z} # :nodoc:
METADATA_LINK_KEYS = %w[
- bug_tracker_uri
- changelog_uri
- documentation_uri
homepage_uri
- mailing_list_uri
+ changelog_uri
source_code_uri
+ documentation_uri
wiki_uri
+ mailing_list_uri
+ bug_tracker_uri
+ download_uri
funding_uri
].freeze # :nodoc:
@@ -106,6 +107,8 @@ class Gem::SpecificationPolicy
validate_removed_attributes
+ validate_unique_links
+
if @warnings > 0
if strict
error "specification has warnings"
@@ -501,6 +504,22 @@ You have specified rake based extension, but rake is not added as dependency. It
WARNING
end
+ def validate_unique_links
+ links = @specification.metadata.slice(*METADATA_LINK_KEYS)
+ grouped = links.group_by {|_key, uri| uri }
+ grouped.each do |uri, copies|
+ next unless copies.length > 1
+ keys = copies.map(&:first).join("\n ")
+ warning <<~WARNING
+ You have specified the uri:
+ #{uri}
+ for all of the following keys:
+ #{keys}
+ Only the first one will be shown on rubygems.org
+ WARNING
+ end
+ end
+
def warning(statement) # :nodoc:
@warnings += 1