Skip to content
Snippets Groups Projects
Commit e0645f39 authored by Seeker's avatar Seeker
Browse files

cask/audit: detect tag from URL

parent 21e05e2c
No related branches found
No related tags found
No related merge requests found
......@@ -468,8 +468,9 @@ module Cask
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @online
return if user.nil?
# TODO: Detect tag from URL instead of using `cask.version`.
error = SharedAudits.github_release(user, repo, cask.version, cask: cask)
tag = SharedAudits.github_tag_from_url(cask.url)
tag ||= cask.version
error = SharedAudits.github_release(user, repo, tag, cask: cask)
add_error error if error
end
......@@ -481,7 +482,9 @@ module Cask
odebug "Auditing GitLab prerelease"
error = SharedAudits.gitlab_release(user, repo, cask.version)
tag = SharedAudits.gitlab_tag_from_url(cask.url)
tag ||= cask.version
error = SharedAudits.gitlab_release(user, repo, tag)
add_error error if error
end
......
......@@ -784,9 +784,7 @@ module Homebrew
owner = Regexp.last_match(1)
repo = Regexp.last_match(2)
tag = url.match(%r{^https://gitlab\.com/[\w-]+/[\w-]+/-/archive/([^/]+)/})
.to_a
.second
tag = SharedAudits.gitlab_tag_from_url(url)
tag ||= stable.specs[:tag]
tag ||= stable.version
......@@ -797,12 +795,7 @@ module Homebrew
when %r{^https://github.com/([\w-]+)/([\w-]+)}
owner = Regexp.last_match(1)
repo = Regexp.last_match(2)
tag = url.match(%r{^https://github\.com/[\w-]+/[\w-]+/archive/([^/]+)\.(tar\.gz|zip)$})
.to_a
.second
tag ||= url.match(%r{^https://github\.com/[\w-]+/[\w-]+/releases/download/([^/]+)/})
.to_a
.second
tag = SharedAudits.github_tag_from_url(url)
tag ||= formula.stable.specs[:tag]
if @online
......
......@@ -164,4 +164,22 @@ module SharedAudits
"Bitbucket repository not notable enough (<30 forks and <75 watchers)"
end
def github_tag_from_url(url)
url = url.to_s
tag = url.match(%r{^https://github\.com/[\w-]+/[\w-]+/archive/([^/]+)\.(tar\.gz|zip)$})
.to_a
.second
tag ||= url.match(%r{^https://github\.com/[\w-]+/[\w-]+/releases/download/([^/]+)/})
.to_a
.second
tag
end
def gitlab_tag_from_url(url)
url = url.to_s
url.match(%r{^https://gitlab\.com/[\w-]+/[\w-]+/-/archive/([^/]+)/})
.to_a
.second
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment