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

utils/github: better handle blank scopes. #6135

Merged
merged 1 commit into from May 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions Library/Homebrew/utils/github.rb
Expand Up @@ -126,10 +126,13 @@ def api_credentials_error_message(response_headers, needed_scopes)
@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
Expand Down