From 2e817d2644980c8b9f9016ff77c895d62b6d9b2e Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 15 May 2019 09:18:05 +0100 Subject: [PATCH] utils/github: better handle blank scopes. If both provided and required scopes are blank then we cannot display a good error message so don't try. Fixes #6134. --- Library/Homebrew/utils/github.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 9b241f870b..d3237346c4 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -126,10 +126,13 @@ module GitHub @api_credentials_error_message ||= begin unauthorized = (response_headers["http/1.1"] == "401 Unauthorized") scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ") - if unauthorized && scopes.empty? + if unauthorized && scopes.blank? needed_human_scopes = needed_scopes.join(", ") - needed_human_scopes = "none" if needed_human_scopes.empty? credentials_scopes = response_headers["x-oauth-scopes"] + return if needed_human_scopes.blank? && credentials_scopes.blank? + + needed_human_scopes = "none" if needed_human_scopes.blank? + credentials_scopes = "none" if credentials_scopes.blank? case GitHub.api_credentials_type when :keychain