From aa051c0644eb2cd3f2a0b8d2bfddc39463c499a0 Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Thu, 1 Aug 2024 11:36:36 -0400 Subject: [PATCH] attestation: specialize error when `gh` is old See https://github.com/Homebrew/homebrew-core/issues/177384#issuecomment-2263195832. Signed-off-by: William Woodruff --- Library/Homebrew/attestation.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) 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