Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attestation: specialize error when gh is old #17926

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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