Revert "disable license check for new formulae"

This commit is contained in:
Mike McQuaid 2020-07-02 09:04:58 +01:00 committed by GitHub
parent 05a7a2ccc8
commit 97f68e6a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 12 deletions

View File

@ -333,21 +333,23 @@ module Homebrew
].freeze ].freeze
def audit_license def audit_license
return if formula.license.blank? if formula.license.present?
if @spdx_data["licenses"].any? { |lic| lic["licenseId"] == formula.license }
return unless @online
if @spdx_data["licenses"].any? { |lic| lic["licenseId"] == formula.license } user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula
return unless @online return if user.blank?
user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula github_license = GitHub.get_repo_license(user, repo)
return if user.blank? return if github_license && (github_license == formula.license)
github_license = GitHub.get_repo_license(user, repo) problem "License mismatch - GitHub license is: #{github_license}, "\
return if github_license && (github_license == formula.license) "but Formulae license states: #{formula.license}."
else
problem "License mismatch - GitHub license is: #{github_license}, "\ problem "#{formula.license} is not a standard SPDX license."
"but Formulae license states: #{formula.license}." end
else elsif @new_formula
problem "#{formula.license} is not a standard SPDX license." problem "No license specified for package."
end end
end end

View File

@ -99,6 +99,18 @@ module Homebrew
expect(fa.problems).to be_empty expect(fa.problems).to be_empty
end end
it "detects no license info" do
fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true
class Foo < Formula
url "https://brew.sh/foo-1.0.tgz"
license ""
end
RUBY
fa.audit_license
expect(fa.problems.first).to match "No license specified for package."
end
it "detects if license is not a standard spdx-id" do it "detects if license is not a standard spdx-id" do
fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true
class Foo < Formula class Foo < Formula