diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index a4007aadb7c67..18cc8d84e57d8 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -594,7 +594,7 @@ def apply_redirected_remote!(redirected_remote, quiet: false) def git_command!(args, chdir: nil) require "system_command" - SystemCommand.run!("git", args:, chdir:, print_stderr: true) + SystemCommand.run!("git", args:, chdir:, env: { "GIT_TERMINAL_PROMPT" => "0" }, print_stderr: true) end private :git_command! diff --git a/Library/Homebrew/test/tap_spec.rb b/Library/Homebrew/test/tap_spec.rb index b07b1e08d49c9..5d7e28a751ba4 100644 --- a/Library/Homebrew/test/tap_spec.rb +++ b/Library/Homebrew/test/tap_spec.rb @@ -619,6 +619,15 @@ def setup_completion(link:) end describe "#install" do + it "disables terminal prompts for git commands" do + require "system_command" + + expect(SystemCommand).to receive(:run!) + .with("git", args: %w[fetch], chdir: path, env: { "GIT_TERMINAL_PROMPT" => "0" }, print_stderr: true) + + homebrew_foo_tap.send(:git_command!, %w[fetch], chdir: path) + end + it "raises an error when the Tap is already tapped" do setup_git_repo already_tapped_tap = described_class.fetch("Homebrew", "foo")