From eae95670efbf68800725b4baf1a3ce74d4e8f72b Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Sun, 24 Sep 2023 21:05:37 +0300 Subject: [PATCH] Separate logic that shows warning from path detection --- Library/Homebrew/dev-cmd/edit.rb | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb index 7d651dde33..b662a44ebb 100644 --- a/Library/Homebrew/dev-cmd/edit.rb +++ b/Library/Homebrew/dev-cmd/edit.rb @@ -50,19 +50,22 @@ module Homebrew [HOMEBREW_REPOSITORY] end else - edit_api_message_displayed = T.let(false, T::Boolean) - args.named.to_paths.select do |path| + expanded_paths = args.named.to_paths + expanded_paths.each do |path| + if path.exist? && + (path.core_formula_path? || path.core_cask_path? || path.core_formula_tap? || path.core_cask_tap?) && + !Homebrew::EnvConfig.no_install_from_api? && + !Homebrew::EnvConfig.no_env_hints? + opoo <<~EOS + `brew install` ignores locally edited #{(path.core_cask_path? || path.core_cask_tap?) ? "casks" : "formulae"} if + `HOMEBREW_NO_INSTALL_FROM_API` is not set. + EOS + break + end + end + + expanded_paths.select do |path| if path.exist? - if (path.core_formula_path? || path.core_cask_path? || path.core_formula_tap? || path.core_cask_tap?) && - !edit_api_message_displayed && - !Homebrew::EnvConfig.no_install_from_api? && - !Homebrew::EnvConfig.no_env_hints? - opoo <<~EOS - `brew install` ignores locally edited #{(path.core_cask_path? || path.core_cask_tap?) ? "casks" : "formulae"} if - `HOMEBREW_NO_INSTALL_FROM_API` is not set. - EOS - edit_api_message_displayed = true - end next path end