audit(github): prefer /archive/refs/tags urls over /archive
Signed-off-by: Rui Chen <rui@chenrui.dev>
This commit is contained in:
parent
35746e0a6b
commit
a496f6708e
@ -217,6 +217,13 @@ module RuboCop
|
|||||||
problem "Use /archive/ URLs for GitHub tarballs (url is #{url})."
|
problem "Use /archive/ URLs for GitHub tarballs (url is #{url})."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
archive_ref_tags_gh_pattern = %r{https://.*github.*/archive(?!/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
|
# Don't use GitHub .zip files
|
||||||
zip_gh_pattern = %r{https://.*github.*/(archive|releases)/.*\.zip$}
|
zip_gh_pattern = %r{https://.*github.*/(archive|releases)/.*\.zip$}
|
||||||
audit_urls(urls, zip_gh_pattern) do |_, url|
|
audit_urls(urls, zip_gh_pattern) do |_, url|
|
||||||
|
|||||||
@ -157,7 +157,7 @@ module SharedAudits
|
|||||||
|
|
||||||
def github_tag_from_url(url)
|
def github_tag_from_url(url)
|
||||||
url = url.to_s
|
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
|
.to_a
|
||||||
.second
|
.second
|
||||||
tag ||= url.match(%r{^https://github\.com/[\w-]+/[\w-]+/releases/download/([^/]+)/})
|
tag ||= url.match(%r{^https://github\.com/[\w-]+/[\w-]+/releases/download/([^/]+)/})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user