Skip to content

Commit

Permalink
attestation: improve error message when gh is too old
Browse files Browse the repository at this point in the history
  • Loading branch information
nandahkrishna committed Jul 14, 2024
1 parent b9da669 commit c82ed9e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Library/Homebrew/attestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module Attestation
# @api private
HOMEBREW_CORE_REPO = "Homebrew/homebrew-core"

# @api private
GH_ATTESTATION_MIN_VERSION = Version.new("2.49.0").freeze

# @api private
BACKFILL_REPO = "trailofbits/homebrew-brew-verify"

Expand Down Expand Up @@ -104,6 +107,11 @@ def self.check_attestation(bottle, signing_repo, signing_workflow = nil, subject
# Even if we have credentials, they may be invalid or malformed.
raise GhAuthNeeded, "invalid credentials" if e.status.exitstatus == 4

if Formula["gh"].any_installed_version.version < GH_ATTESTATION_MIN_VERSION
raise e,
"`gh` is too old, you must run `brew upgrade gh` to continue."
end

raise InvalidAttestationError, "attestation verification failed: #{e}"
end

Expand Down

0 comments on commit c82ed9e

Please # to comment.