Skip to content

Commit

Permalink
attestation: specialize error when gh is old
Browse files Browse the repository at this point in the history
See Homebrew/homebrew-core#177384 (comment).

Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw authored and ZhongRuoyu committed Aug 13, 2024
1 parent 59cd3c3 commit b6c2e0d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Library/Homebrew/attestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit b6c2e0d

Please sign in to comment.