From 557b1d09a2c228a38d9c0792e5685541d0b8a6cc Mon Sep 17 00:00:00 2001 From: lionellloh Date: Sun, 12 Jul 2020 12:35:27 +0800 Subject: [PATCH] correct logic for standard license checking --- Library/Homebrew/dev-cmd/audit.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 4655594847..961f64d3d1 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -330,7 +330,16 @@ module Homebrew def audit_license if formula.license.present? - if formula.license.any? { |lic| @spdx_data["licenses"].any? { |standard_lic| standard_lic["licenseId"] == lic } } + non_standard_licenses = [] + formula.license.each do |lic| + next if @spdx_data["licenses"].any? { |standard_lic| standard_lic["licenseId"] == lic } + non_standard_licenses << lic + end + + if non_standard_licenses.present? + problem "Formula #{formula.name} contains non standard SPDX license: #{non_standard_licenses} " + end + return unless @online user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula @@ -341,9 +350,8 @@ module Homebrew problem "License mismatch - GitHub license is: #{Array(github_license)}, "\ "but Formulae license states: #{formula.license}." - else - problem "#{formula.license} is not a standard SPDX license." - end + + elsif @new_formula problem "No license specified for package." end