migrate license mismatch allowlist to Homebrew/core

This commit is contained in:
Rylan Polster 2020-11-17 17:57:48 -05:00
parent 12495bc804
commit 899783b35a
2 changed files with 19 additions and 6 deletions

View File

@ -165,11 +165,6 @@ module Homebrew
"LGPL-3.0" => ["LGPL-3.0-only", "LGPL-3.0-or-later"], "LGPL-3.0" => ["LGPL-3.0-only", "LGPL-3.0-or-later"],
}.freeze }.freeze
PERMITTED_FORMULA_LICENSE_MISMATCHES = {
"cmockery" => "0.1.2",
"scw@1" => "1.20",
}.freeze
def audit_license def audit_license
if formula.license.present? if formula.license.present?
licenses, exceptions = SPDX.parse_license_expression formula.license licenses, exceptions = SPDX.parse_license_expression formula.license
@ -213,7 +208,7 @@ module Homebrew
return unless github_license return unless github_license
return if (licenses + ["NOASSERTION"]).include?(github_license) return if (licenses + ["NOASSERTION"]).include?(github_license)
return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| licenses.include? license } return if PERMITTED_LICENSE_MISMATCHES[github_license]&.any? { |license| licenses.include? license }
return if PERMITTED_FORMULA_LICENSE_MISMATCHES[formula.name] == formula.version return if tap_audit_exception :permitted_formula_license_mismatches, formula.name
problem "Formula license #{licenses} does not match GitHub license #{Array(github_license)}." problem "Formula license #{licenses} does not match GitHub license #{Array(github_license)}."
@ -821,6 +816,7 @@ module Homebrew
end end
def tap_audit_exception(list, formula, value = nil) def tap_audit_exception(list, formula, value = nil)
return false if @tap_audit_exceptions.blank?
return false unless @tap_audit_exceptions.key? list return false unless @tap_audit_exceptions.key? list
list = @tap_audit_exceptions[list] list = @tap_audit_exceptions[list]

View File

@ -423,6 +423,23 @@ module Homebrew
.to eq 'Formula license ["0BSD"] does not match GitHub license ["GPL-3.0"].' .to eq 'Formula license ["0BSD"] does not match GitHub license ["GPL-3.0"].'
end end
it "allows a formula-specified license that differes from its GitHub "\
"repository for formulae on the mismatched license allowlist" do
formula_text = <<~RUBY
class Cask < Formula
url "https://github.com/cask/cask/archive/v0.8.4.tar.gz"
head "https://github.com/cask/cask.git"
license "0BSD"
end
RUBY
fa = formula_auditor "cask", formula_text, spdx_license_data: spdx_license_data,
online: true, core_tap: true, new_formula: true,
tap_audit_exceptions: { permitted_formula_license_mismatches: ["cask"] }
fa.audit_license
expect(fa.problems).to be_empty
end
it "checks online and detects that an array of license does not contain "\ it "checks online and detects that an array of license does not contain "\
"what is indicated on its Github repository" do "what is indicated on its Github repository" do
formula_text = <<~RUBY formula_text = <<~RUBY