diff options
| author | Mike McQuaid | 2016-10-30 15:38:19 -0400 |
|---|---|---|
| committer | Mike McQuaid | 2016-10-30 15:38:19 -0400 |
| commit | 3c7446f3ff802a802de3bd923e9a0af486575f3d (patch) | |
| tree | d114f93e1633c5717198cf6f39c60eb96823172c /Library/Homebrew/cmd/gist-logs.rb | |
| parent | 8d5df2ea8769f48fc8b9c145abc8fc1329a650cb (diff) | |
| download | brew-3c7446f3ff802a802de3bd923e9a0af486575f3d.tar.bz2 | |
Improve GitHub API scopes output.
Improve the GitHub API scope and token related messaging by
autopopulating the scopes we need on the new scopes page and, in the
case of a lacking a scope we need, output what scope was required.
Also, DRY up the personal access token code.
Diffstat (limited to 'Library/Homebrew/cmd/gist-logs.rb')
| -rw-r--r-- | Library/Homebrew/cmd/gist-logs.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/gist-logs.rb b/Library/Homebrew/cmd/gist-logs.rb index e55eefc17..5cacd50b6 100644 --- a/Library/Homebrew/cmd/gist-logs.rb +++ b/Library/Homebrew/cmd/gist-logs.rb @@ -47,13 +47,16 @@ module Homebrew if ARGV.include?("--new-issue") || ARGV.switch?("n") if GitHub.api_credentials_type == :none - puts "You can create a personal access token: https://github.com/settings/tokens" - puts "and then set HOMEBREW_GITHUB_API_TOKEN as authentication method." - puts + puts <<-EOS.undent + You can create a new personal access token: + #{GitHub::ALL_SCOPES_URL} + and then set the new HOMEBREW_GITHUB_API_TOKEN as the authentication method. + + EOS login! end - url = new_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url) + url = create_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url) end puts url if url @@ -103,13 +106,17 @@ module Homebrew end def create_gist(files, description) + url = "https://api.github.com/gists" data = { "public" => true, "files" => files, "description" => description } - GitHub.open("https://api.github.com/gists", data)["html_url"] + scopes = GitHub::CREATE_GIST_SCOPES + GitHub.open(url, data: data, scopes: scopes)["html_url"] end - def new_issue(repo, title, body) + def create_issue(repo, title, body) + url = "https://api.github.com/repos/#{repo}/issues" data = { "title" => title, "body" => body } - GitHub.open("https://api.github.com/repos/#{repo}/issues", data)["html_url"] + scopes = GitHub::CREATE_ISSUE_SCOPES + GitHub.open(url, data: data, scopes: scopes)["html_url"] end def gist_logs |
