From 285b0bc94154adb8b9b89038589e3194e80ece3d Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Tue, 11 Apr 2017 01:39:44 +0100 Subject: [PATCH 1/3] caveats: tweak keg_only wording Current: ``` This formula is keg-only, which means it was not symlinked into /usr/local. Qt has CMake issues when linked ``` After: ``` This formula is keg-only, which means it was not symlinked into /usr/local, because Qt has CMake issues when linked. ``` --- Library/Homebrew/caveats.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index b7c0a60c92..2032e9ff1a 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -44,8 +44,10 @@ class Caveats def keg_only_text return unless f.keg_only? - s = "This formula is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX}." - s << "\n\n#{f.keg_only_reason}\n" + s = <<-EOS.undent + This formula is keg-only, which means it was not symlinked into #{HOMEBREW_PREFIX}, + because #{f.keg_only_reason}. + EOS if f.bin.directory? || f.sbin.directory? s << "\nIf you need to have this software first in your PATH run:\n" if f.bin.directory? From 85053b1476f9aee0f4608ea77f1594bec7014ac1 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Fri, 28 Apr 2017 04:53:52 +0100 Subject: [PATCH 2/3] audit: add audit_keg_only_style --- Library/Homebrew/dev-cmd/audit.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 7824052074..be53e1d6fd 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -489,6 +489,37 @@ class FormulaAuditor EOS end + def audit_keg_only_style + return unless @strict + return unless formula.keg_only? + + whitelist = %w[ + Apple + macOS + OS + Homebrew + Xcode + GPG + GNOME + BSD + ].freeze + + reason = formula.keg_only_reason.to_s + # Formulae names can legitimately be uppercase/lowercase/both. + name = Regexp.new(formula.name, Regexp::IGNORECASE) + reason.sub!(name, "") + first_word = reason.split[0] + + if reason =~ /^[A-Z]/ && !reason.start_with?(*whitelist) + problem <<-EOS.undent + '#{first_word}' from the keg_only reason should be '#{first_word.downcase}'. + EOS + end + + return unless reason.end_with?(".") + problem "keg_only reason should not end with a period." + end + def audit_options formula.options.each do |o| if o.name == "32-bit" From 25ffa301b8a4f3613886158f7a8848ca53e634f3 Mon Sep 17 00:00:00 2001 From: Dominyk Tiller Date: Fri, 28 Apr 2017 04:56:22 +0100 Subject: [PATCH 3/3] formula_support: keg_only style harmonisation --- Library/Homebrew/formula_support.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index b8476f5cc7..4d963a55e1 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -32,30 +32,30 @@ class KegOnlyReason return @explanation unless @explanation.empty? case @reason when :versioned_formula then <<-EOS.undent - This is an alternate version of another formula. + this is an alternate version of another formula EOS when :provided_by_macos, :provided_by_osx then <<-EOS.undent macOS already provides this software and installing another version in - parallel can cause all kinds of trouble. + parallel can cause all kinds of trouble EOS when :shadowed_by_macos, :shadowed_by_osx then <<-EOS.undent macOS provides similar software and installing this software in - parallel can cause all kinds of trouble. + parallel can cause all kinds of trouble EOS when :provided_pre_mountain_lion then <<-EOS.undent - macOS already provides this software in versions before Mountain Lion. + macOS already provides this software in versions before Mountain Lion EOS when :provided_pre_mavericks then <<-EOS.undent - macOS already provides this software in versions before Mavericks. + macOS already provides this software in versions before Mavericks EOS when :provided_pre_el_capitan then <<-EOS.undent - macOS already provides this software in versions before El Capitan. + macOS already provides this software in versions before El Capitan EOS when :provided_until_xcode43 then <<-EOS.undent - Xcode provides this software prior to version 4.3. + Xcode provides this software prior to version 4.3 EOS when :provided_until_xcode5 then <<-EOS.undent - Xcode provides this software prior to version 5. + Xcode provides this software prior to version 5 EOS else @reason