From 8839ccfe72286f5e90a16897839b5f4016e3964f Mon Sep 17 00:00:00 2001 From: Nanda H Krishna Date: Mon, 15 Jul 2024 16:42:43 -0400 Subject: [PATCH] Fix tests for attestations --- Library/Homebrew/attestation.rb | 3 +-- Library/Homebrew/cmd/install.rb | 2 +- Library/Homebrew/cmd/reinstall.rb | 2 +- Library/Homebrew/cmd/upgrade.rb | 2 +- Library/Homebrew/test/attestation_spec.rb | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/attestation.rb b/Library/Homebrew/attestation.rb index e62564394ea7e..0e4b305ac919c 100644 --- a/Library/Homebrew/attestation.rb +++ b/Library/Homebrew/attestation.rb @@ -53,7 +53,6 @@ def self.enabled? return true if Homebrew::EnvConfig.verify_attestations? return false if GitHub::API.credentials.blank? return false if ENV.fetch("CI", false) - return false unless Formula["gh"].any_version_installed? Homebrew::EnvConfig.developer? || Homebrew::EnvConfig.devcmdrun? end @@ -70,7 +69,7 @@ def self.gh_executable return @gh_executable if @gh_executable.present? with_env(HOMEBREW_NO_VERIFY_ATTESTATIONS: "1") do - @gh_executable = ensure_executable!("gh") + @gh_executable = ensure_executable!("gh", reason: "verifying attestations") gh_version = Version.new(system_command!(@gh_executable, args: ["--version"], print_stderr: false) .stdout.match(/\d+(?:\.\d+)+/i).to_s) diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb index bab0b2e90375b..9b8b9d59e4c45 100644 --- a/Library/Homebrew/cmd/install.rb +++ b/Library/Homebrew/cmd/install.rb @@ -267,7 +267,7 @@ def run if formulae.include?(Formula["gh"]) formulae.unshift(T.must(formulae.delete(Formula["gh"]))) else - Homebrew::Attestation.ensure_gh_installed! + Homebrew::Attestation.gh_executable end end diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index 37046832f0834..5f8a75144d55e 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -128,7 +128,7 @@ def run if formulae.include?(Formula["gh"]) formulae.unshift(T.must(formulae.delete(Formula["gh"]))) else - Homebrew::Attestation.ensure_gh_installed! + Homebrew::Attestation.gh_executable end end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 75645c94f25fe..cab4f27556c2e 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -138,7 +138,7 @@ def run if formulae.include?(Formula["gh"]) formulae.unshift(formulae.delete(Formula["gh"])) else - Homebrew::Attestation.ensure_gh_installed! + Homebrew::Attestation.gh_executable end end diff --git a/Library/Homebrew/test/attestation_spec.rb b/Library/Homebrew/test/attestation_spec.rb index 1df9afd6e384d..850b4508922bb 100644 --- a/Library/Homebrew/test/attestation_spec.rb +++ b/Library/Homebrew/test/attestation_spec.rb @@ -77,7 +77,7 @@ it "calls ensure_executable and ensure_formula_installed" do expect(described_class).to receive(:ensure_executable!) - .with("gh") + .with("gh", reason: "verifying attestations") .and_return(fake_old_gh) expect(described_class).to receive(:ensure_formula_installed!)