Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Library/Homebrew/attestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ def self.gh_executable
# NOTE: We set HOMEBREW_NO_VERIFY_ATTESTATIONS when installing `gh` itself,
# to prevent a cycle during bootstrapping. This can eventually be resolved
# by vendoring a pure-Ruby Sigstore verifier client.
with_env(HOMEBREW_NO_VERIFY_ATTESTATIONS: "1") do
@gh_executable = ensure_executable!("gh", reason: "verifying attestations", latest: true)
@gh_executable = with_env(HOMEBREW_NO_VERIFY_ATTESTATIONS: "1") do
ensure_executable!("gh", reason: "verifying attestations", latest: true)
end

T.must(@gh_executable)
end

# Prioritize installing `gh` first if it's in the formula list
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/extend/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ def redirect_stdout(file, &_block)
out.close
end

# Ensure the given executable is exist otherwise install the brewed version
sig { params(name: String, formula_name: T.nilable(String), reason: String, latest: T::Boolean).returns(T.nilable(Pathname)) }
# Ensure the given executable exists otherwise install the brewed version
sig { params(name: String, formula_name: T.nilable(String), reason: String, latest: T::Boolean).returns(Pathname) }
def ensure_executable!(name, formula_name = nil, reason: "", latest: false)
formula_name ||= name

Expand All @@ -197,8 +197,8 @@ def ensure_executable!(name, formula_name = nil, reason: "", latest: false)
# path where available, since the former is stable during upgrades.
HOMEBREW_PREFIX/"opt/#{formula_name}/bin/#{name}",
HOMEBREW_PREFIX/"bin/#{name}",
].compact.first
return executable if executable.exist?
].compact.find(&:exist?)
return executable if executable

require "formula"
Formulary.factory_stub(formula_name).ensure_installed!(reason:, latest:).opt_bin/name
Expand Down
Loading