Skip to content

Commit

Permalink
Fix tests for attestations
Browse files Browse the repository at this point in the history
  • Loading branch information
nandahkrishna committed Jul 17, 2024
1 parent 81e6060 commit 8839ccf
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Library/Homebrew/attestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/reinstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/attestation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
Expand Down

0 comments on commit 8839ccf

Please sign in to comment.