diff --git a/Library/Homebrew/attestation.rb b/Library/Homebrew/attestation.rb index 853643465fa30..7cc4bce456422 100644 --- a/Library/Homebrew/attestation.rb +++ b/Library/Homebrew/attestation.rb @@ -52,6 +52,12 @@ class GhAuthNeeded < RuntimeError; end # @api private class GhAuthInvalid < RuntimeError; end + # Raised if the version of `gh` invoked is too old to support + # attestations. + # + # @api private + class GhTooOld < RuntimeError; end + # Returns whether attestation verification is enabled. # # @api private @@ -143,6 +149,11 @@ def self.check_attestation(bottle, signing_repo, signing_workflow = nil, subject raise MissingAttestationError, "attestation not found: #{e}" if e.stderr.include?("HTTP 404: Not Found") + if e.stderr.include?("unknown command \"attestation\" for \"gh\"") + raise GhTooOld, + "your version of `gh` is too old; run `brew upgrade gh` to continue" + end + raise InvalidAttestationError, "attestation verification failed: #{e}" end