From 97f68e6a3a5fb13f34f87c364687f0145d8ff3d1 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Thu, 2 Jul 2020 09:04:58 +0100 Subject: [PATCH] Revert "disable license check for new formulae" --- Library/Homebrew/dev-cmd/audit.rb | 26 +++++++++++---------- Library/Homebrew/test/dev-cmd/audit_spec.rb | 12 ++++++++++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index ec7a3a6e37..8c2beedfca 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -333,21 +333,23 @@ module Homebrew ].freeze 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 } - return unless @online + user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula + return if user.blank? - user, repo = get_repo_data(%r{https?://github\.com/([^/]+)/([^/]+)/?.*}) if @new_formula - return if user.blank? + github_license = GitHub.get_repo_license(user, repo) + return if github_license && (github_license == formula.license) - github_license = GitHub.get_repo_license(user, repo) - return if github_license && (github_license == formula.license) - - problem "License mismatch - GitHub license is: #{github_license}, "\ - "but Formulae license states: #{formula.license}." - else - problem "#{formula.license} is not a standard SPDX license." + problem "License mismatch - GitHub license is: #{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 end diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 26978b5069..c1418223c5 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -99,6 +99,18 @@ module Homebrew expect(fa.problems).to be_empty 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 fa = formula_auditor "foo", <<~RUBY, spdx_data: spdx_data, new_formula: true class Foo < Formula