diff --git a/Library/Homebrew/attestation.rb b/Library/Homebrew/attestation.rb index 0e4b305ac9..7dd23bdad4 100644 --- a/Library/Homebrew/attestation.rb +++ b/Library/Homebrew/attestation.rb @@ -74,6 +74,10 @@ module Homebrew gh_version = Version.new(system_command!(@gh_executable, args: ["--version"], print_stderr: false) .stdout.match(/\d+(?:\.\d+)+/i).to_s) if gh_version < GH_ATTESTATION_MIN_VERSION + if Formula["gh"].version < GH_ATTESTATION_MIN_VERSION + raise "#{@gh_executable} is too old, you must upgrade it to >=#{GH_ATTESTATION_MIN_VERSION} to continue" + end + @gh_executable = ensure_formula_installed!("gh", latest: true, reason: "verifying attestations").opt_bin/"gh" end diff --git a/Library/Homebrew/test/attestation_spec.rb b/Library/Homebrew/test/attestation_spec.rb index 850b450892..b82dc11565 100644 --- a/Library/Homebrew/test/attestation_spec.rb +++ b/Library/Homebrew/test/attestation_spec.rb @@ -70,6 +70,10 @@ RSpec.describe Homebrew::Attestation do describe "::gh_executable" do before do + allow(Formulary).to receive(:factory) + .with("gh") + .and_return(instance_double(Formula, version: Version.new("2.49.0"))) + allow(described_class).to receive(:system_command!) .with(fake_old_gh, args: ["--version"], print_stderr: false) .and_return(fake_old_gh_version)