From 15a868c5e65cc1fc5bdc045db6ee5cf323118e8b Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sat, 12 Dec 2020 17:30:30 -0500 Subject: [PATCH] dev-cmd/livecheck: respect --cask and --formula When running `brew livecheck --cask` or `brew livecheck --formula`, livecheck wasn't properly respecting these flags. It should have worked by only including the casks or formulae in the watchlist but instead these flags were treating all the names in the watchlist as formulae or casks, which doesn't work properly. This addresses the issue by always using `#to_formulae_and_casks` on the watchlist names and then using `#reject` to conditionally exclude formulae or casks based on whether the related flags were passed to `brew livecheck`. --- Library/Homebrew/dev-cmd/livecheck.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/dev-cmd/livecheck.rb b/Library/Homebrew/dev-cmd/livecheck.rb index 1546bcb7ec..b2929339a1 100644 --- a/Library/Homebrew/dev-cmd/livecheck.rb +++ b/Library/Homebrew/dev-cmd/livecheck.rb @@ -86,13 +86,11 @@ module Homebrew names = Pathname.new(WATCHLIST_PATH).read.lines .reject { |line| line.start_with?("#") || line.blank? } .map(&:strip) + named_args = T.unsafe(CLI::NamedArgs).new(*names) - if args.formula? - named_args.to_formulae - elsif args.cask? - named_args.to_casks - else - named_args.to_formulae_and_casks + named_args.to_formulae_and_casks.reject do |formula_or_cask| + (args.formula? && !formula_or_cask.is_a?(Formula)) || + (args.cask? && !formula_or_cask.is_a?(Cask::Cask)) end rescue Errno::ENOENT => e onoe e