From 57b7999843b2bfd3e0f097ae092963eae6ae9983 Mon Sep 17 00:00:00 2001 From: Sohan Honavar Date: Sat, 10 Feb 2024 02:41:11 +0530 Subject: [PATCH 1/4] Improved the GitHub link that is generated when the required scope of the token has mismatched with the present scope --- Library/Homebrew/utils/github/api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/utils/github/api.rb b/Library/Homebrew/utils/github/api.rb index bff224f126..f058762c19 100644 --- a/Library/Homebrew/utils/github/api.rb +++ b/Library/Homebrew/utils/github/api.rb @@ -208,7 +208,7 @@ module GitHub Your #{what} credentials do not have sufficient scope! Scopes required: #{needed_scopes} Scopes present: #{credentials_scopes} - #{GitHub.pat_blurb} + #{GitHub.pat_blurb(needed_scopes.split(", "))} EOS end From ca85c5355f665104e96232ba2e5c90e56a503e5c Mon Sep 17 00:00:00 2001 From: Sohan Honavar Date: Sat, 10 Feb 2024 03:50:08 +0530 Subject: [PATCH 2/4] Reused the variable as per the review suggestion --- Library/Homebrew/utils/github/api.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/utils/github/api.rb b/Library/Homebrew/utils/github/api.rb index f058762c19..c6b0e8ebe9 100644 --- a/Library/Homebrew/utils/github/api.rb +++ b/Library/Homebrew/utils/github/api.rb @@ -197,6 +197,8 @@ module GitHub scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ") needed_scopes = Set.new(scopes || needed_scopes) + github_permission_link = GitHub.pat_blurb(needed_scopes) + credentials_scopes = response_headers["x-oauth-scopes"] return if needed_scopes.subset?(Set.new(credentials_scopes.to_s.split(", "))) @@ -208,7 +210,7 @@ module GitHub Your #{what} credentials do not have sufficient scope! Scopes required: #{needed_scopes} Scopes present: #{credentials_scopes} - #{GitHub.pat_blurb(needed_scopes.split(", "))} + #{github_permission_link} EOS end From 3dc104167e5ecdc2772d607e3d9f3f2eba6140f5 Mon Sep 17 00:00:00 2001 From: Sohan Honavar Date: Sat, 10 Feb 2024 11:35:53 +0530 Subject: [PATCH 3/4] Update Library/Homebrew/utils/github/api.rb --- Library/Homebrew/utils/github/api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/utils/github/api.rb b/Library/Homebrew/utils/github/api.rb index c6b0e8ebe9..786e6a636a 100644 --- a/Library/Homebrew/utils/github/api.rb +++ b/Library/Homebrew/utils/github/api.rb @@ -197,11 +197,11 @@ module GitHub scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ") needed_scopes = Set.new(scopes || needed_scopes) - github_permission_link = GitHub.pat_blurb(needed_scopes) credentials_scopes = response_headers["x-oauth-scopes"] return if needed_scopes.subset?(Set.new(credentials_scopes.to_s.split(", "))) + github_permission_link = GitHub.pat_blurb(needed_scopes.to_a) needed_scopes = needed_scopes.to_a.join(", ").presence || "none" credentials_scopes = "none" if credentials_scopes.blank? From 94afce5b13af058bb9e2e4f9dcd9be32bed6c06a Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 10 Feb 2024 12:10:55 +0100 Subject: [PATCH 4/4] Remove empty line. --- Library/Homebrew/utils/github/api.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/Library/Homebrew/utils/github/api.rb b/Library/Homebrew/utils/github/api.rb index 786e6a636a..9e4a65c53a 100644 --- a/Library/Homebrew/utils/github/api.rb +++ b/Library/Homebrew/utils/github/api.rb @@ -197,7 +197,6 @@ module GitHub scopes = response_headers["x-accepted-oauth-scopes"].to_s.split(", ") needed_scopes = Set.new(scopes || needed_scopes) - credentials_scopes = response_headers["x-oauth-scopes"] return if needed_scopes.subset?(Set.new(credentials_scopes.to_s.split(", ")))