Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SharedAudits::gitlab_release. #8615

Merged
merged 2 commits into from Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions Library/Homebrew/cask/audit.rb
Expand Up @@ -481,10 +481,8 @@ def check_gitlab_prerelease_version

odebug "Auditing GitLab prerelease"

metadata = SharedAudits.gitlab_release_data(user, repo, cask.version)
return if metadata.nil?

add_error "#{cask.version} is a GitLab prerelease" if Date.parse(metadata["released_at"]) > Date.today
error = SharedAudits.gitlab_release(user, repo, cask.version)
add_error error if error
end

def check_github_repository_archived
Expand Down
14 changes: 8 additions & 6 deletions Library/Homebrew/dev-cmd/audit.rb
Expand Up @@ -701,8 +701,6 @@ def get_repo_data(regex)
"libepoxy" => "1.5",
}.freeze

GITLAB_PRERELEASE_ALLOWLIST = {}.freeze

# version_prefix = stable_version_string.sub(/\d+$/, "")
# version_prefix = stable.version.major_minor

Expand Down Expand Up @@ -786,11 +784,15 @@ def audit_specs
owner = Regexp.last_match(1)
repo = Regexp.last_match(2)

return unless @online && (release = SharedAudits.gitlab_release_data(owner, repo, stable.version))
tag = url.match(%r{^https://gitlab\.com/[\w-]+/[\w-]+/-/archive/([^/]+)/})
.to_a
.second
tag ||= stable.specs[:tag]
tag ||= stable.version

release_date = Date.parse(release["released_at"])
if release_date > Date.today && (GITLAB_PRERELEASE_ALLOWLIST[formula.name] != formula.version)
problem "#{stable.version} is a GitLab prerelease"
if @online
error = SharedAudits.gitlab_release(owner, repo, tag, formula: formula)
problem error if error
end
when %r{^https://github.com/([\w-]+)/([\w-]+)}
owner = Regexp.last_match(1)
Expand Down
12 changes: 12 additions & 0 deletions Library/Homebrew/utils/shared_audits.rb
Expand Up @@ -84,6 +84,18 @@ def gitlab_release_data(user, repo, tag)
@gitlab_release_data[id]
end

GITLAB_PRERELEASE_ALLOWLIST = {}.freeze

def gitlab_release(user, repo, tag, formula: nil)
release = gitlab_release_data(user, repo, tag)
return unless release

return if Date.parse(release["released_at"]) <= Date.today
return if formula && GITLAB_PRERELEASE_ALLOWLIST[formula.name] == formula.version

"#{tag} is a GitLab pre-release."
end

def github(user, repo)
metadata = github_repo_data(user, repo)

Expand Down