utils/github: fix false positive API credential error

This commit is contained in:
nandahkrishna 2021-02-03 01:00:43 +05:30
parent d2430bcf50
commit f15681ccd9
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA

View File

@ -150,13 +150,11 @@ module GitHub
return if response_headers.empty?
scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ")
return if scopes.present?
needed_human_scopes = needed_scopes.join(", ")
needed_scopes = Set.new(scopes || needed_scopes)
credentials_scopes = response_headers["x-oauth-scopes"]
return if needed_human_scopes.blank? && credentials_scopes.blank?
return if needed_scopes.subset?(Set.new(credentials_scopes.to_s.split(", ")))
needed_human_scopes = "none" if needed_human_scopes.blank?
needed_scopes = needed_scopes.to_a.join(", ").presence || "none"
credentials_scopes = "none" if credentials_scopes.blank?
what = case api_credentials_type
@ -168,7 +166,7 @@ module GitHub
@api_credentials_error_message ||= onoe <<~EOS
Your #{what} credentials do not have sufficient scope!
Scopes required: #{needed_human_scopes}
Scopes required: #{needed_scopes}
Scopes present: #{credentials_scopes}
Create a personal access token:
#{ALL_SCOPES_URL}