From a7dbd738dd8e211877437c0a71eb69e202e66158 Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Sat, 11 Feb 2023 00:16:11 -0800 Subject: [PATCH] cmd/edit: stop double warning When you don't have EDITOR or HOMEBREW_EDITOR configured `brew edit` printed a double warning. This silences the first of those. --- Library/Homebrew/dev-cmd/edit.rb | 2 +- Library/Homebrew/utils.rb | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/dev-cmd/edit.rb b/Library/Homebrew/dev-cmd/edit.rb index a60d4671c6..04d400d2c9 100644 --- a/Library/Homebrew/dev-cmd/edit.rb +++ b/Library/Homebrew/dev-cmd/edit.rb @@ -45,7 +45,7 @@ module Homebrew paths = if args.named.empty? # Sublime requires opting into the project editing path, # as opposed to VS Code which will infer from the .vscode path - if which_editor == "subl" + if which_editor(silent: true) == "subl" ["--project", "#{HOMEBREW_REPOSITORY}/.sublime/homebrew.sublime-project"] else # If no formulae are listed, open the project root in an editor. diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 1a01ee47a4..c370373254 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -361,7 +361,7 @@ module Kernel end.compact.uniq end - def which_editor + def which_editor(silent: false) editor = Homebrew::EnvConfig.editor return editor if editor @@ -371,11 +371,13 @@ module Kernel end editor ||= "vim" - opoo <<~EOS - Using #{editor} because no editor was set in the environment. - This may change in the future, so we recommend setting EDITOR, - or HOMEBREW_EDITOR to your preferred text editor. - EOS + unless silent + opoo <<~EOS + Using #{editor} because no editor was set in the environment. + This may change in the future, so we recommend setting EDITOR, + or HOMEBREW_EDITOR to your preferred text editor. + EOS + end editor end