Ensure that the gh formula is sufficiently new

This commit is contained in:
Nanda H Krishna 2024-07-17 14:45:59 -04:00
parent 8839ccfe72
commit 6db608f43f
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA
2 changed files with 8 additions and 0 deletions

View File

@ -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

View File

@ -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)