Merge pull request #16126 from chenrui333/github/use-new-archive-urls
audit(github): prefer `/archive/refs/tags` urls over `/archive`
This commit is contained in:
commit
141ac157fd
@ -217,6 +217,13 @@ module RuboCop
|
||||
problem "Use /archive/ URLs for GitHub tarballs (url is #{url})."
|
||||
end
|
||||
|
||||
archive_ref_tags_gh_pattern = %r{https://.*github.*/archive/(?![a-fA-F0-9]{40})(?!refs/tags/).*\.tar\.gz$}
|
||||
audit_urls(urls, archive_ref_tags_gh_pattern) do |_, url|
|
||||
next if url.end_with?(".git")
|
||||
|
||||
problem "Use /archive/refs/tags URLs for GitHub tarballs (url is #{url})."
|
||||
end
|
||||
|
||||
# Don't use GitHub .zip files
|
||||
zip_gh_pattern = %r{https://.*github.*/(archive|releases)/.*\.zip$}
|
||||
audit_urls(urls, zip_gh_pattern) do |_, url|
|
||||
|
||||
@ -157,7 +157,7 @@ module SharedAudits
|
||||
|
||||
def github_tag_from_url(url)
|
||||
url = url.to_s
|
||||
tag = url.match(%r{^https://github\.com/[\w-]+/[\w-]+/archive/([^/]+)\.(tar\.gz|zip)$})
|
||||
tag = url.match(%r{^https://github\.com/[\w-]+/[\w-]+/archive/refs/tags/([^/]+)\.(tar\.gz|zip)$})
|
||||
.to_a
|
||||
.second
|
||||
tag ||= url.match(%r{^https://github\.com/[\w-]+/[\w-]+/releases/download/([^/]+)/})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user