license-forbidden: style fixes

This commit is contained in:
lionellloh 2020-07-02 00:19:54 +08:00 committed by Lionell
parent ed42ed5265
commit e9ff0fac43

View File

@ -95,6 +95,7 @@ module Homebrew
def install def install
install_args.parse install_args.parse
args.named.each do |name| args.named.each do |name|
next if File.exist?(name) next if File.exist?(name)
next if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX next if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
@ -330,11 +331,10 @@ module Homebrew
fi.build_bottle = args.build_bottle? fi.build_bottle = args.build_bottle?
fi.interactive = args.interactive? fi.interactive = args.interactive?
fi.git = args.git? fi.git = args.git?
# fi.prelude fi.prelude
# fi.fetch fi.fetch
# fi.install fi.install
# fi.finish fi.finish
rescue FormulaInstallationAlreadyAttemptedError rescue FormulaInstallationAlreadyAttemptedError
# We already attempted to install f as part of the dependency tree of # We already attempted to install f as part of the dependency tree of
# another formula. In that case, don't generate an error, just move on. # another formula. In that case, don't generate an error, just move on.
@ -345,11 +345,14 @@ module Homebrew
end end
def forbidden_license_check(f) def forbidden_license_check(f)
license_blist = ENV["HOMEBREW_FORBIDDEN_LICENSES"].split(" ") forbidden_licenses = ENV["HOMEBREW_FORBIDDEN_LICENSES"].split(" ")
fi = FormulaInstaller.new(f) fi = FormulaInstaller.new(f)
fi.compute_dependencies.each do |dep, _| fi.compute_dependencies.each do |dep, _|
if license_blist.include? dep.to_formula().license dep_f = dep.to_formula
p "VIOLATION #{dep.name}" next unless forbidden_licenses.include? dep_f.license
end
raise CannotInstallFormulaError, <<~EOS
#The installation of {f.name} has a dependency on #{dep.name} with a forbidden license #{dep_f.license}
EOS
end end
end end