From ff45c2822fa789fccb342d6fcf9341e4a7955de5 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 30 May 2023 01:03:33 +0800 Subject: [PATCH] utils/github/api: fix nil implicit conversion error Fixes Error: no implicit conversion of nil into String https://github.com/Homebrew/homebrew-test-bot/actions/runs/5113802196/jobs/9193401244#step:11:11 --- Library/Homebrew/utils/github/api.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/utils/github/api.rb b/Library/Homebrew/utils/github/api.rb index 4375e6882b..a078e4786a 100644 --- a/Library/Homebrew/utils/github/api.rb +++ b/Library/Homebrew/utils/github/api.rb @@ -60,6 +60,11 @@ module GitHub end end + NO_CREDENTIALS_MESSAGE = <<~MESSAGE + No GitHub credentials found in macOS Keychain, GitHub CLI or the environment. + #{GitHub.pat_blurb} + MESSAGE + # Error when authentication fails. class AuthenticationFailedError < Error def initialize(credentials_type, github_message) @@ -83,6 +88,8 @@ module GitHub HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check: #{Formatter.url("https://github.com/settings/tokens")} EOS + when :none + NO_CREDENTIALS_MESSAGE end super message.freeze end @@ -91,9 +98,7 @@ module GitHub # Error when the user has no GitHub API credentials set at all (macOS keychain, GitHub CLI or envvar). class MissingAuthenticationError < Error def initialize - message = +"No GitHub credentials found in macOS Keychain, GitHub CLI or the environment.\n" - message << GitHub.pat_blurb - super message + super NO_CREDENTIALS_MESSAGE end end