dev-cmd/contributions: Don't fall over if a user's profile is private
- It's possible to hide your contribution graph and not be searchable on GitHub. Let's make sure `brew contributions` doesn't fall over if the user's profile is private (determined by the `/events` user endpoint returning []).
This commit is contained in:
parent
0d5e291fe1
commit
03bd62ca0d
@ -175,14 +175,7 @@ module Homebrew
|
||||
author: GitHub.count_repo_commits(repo_full_name, person, "author", args),
|
||||
committer: GitHub.count_repo_commits(repo_full_name, person, "committer", args),
|
||||
coauthorships: git_log_trailers_cmd(T.must(repo_path), person, "Co-authored-by", args),
|
||||
reviews: GitHub.count_issues(
|
||||
"",
|
||||
is: "pr",
|
||||
repo: repo_full_name,
|
||||
reviewed_by: person,
|
||||
review: "approved",
|
||||
args: args,
|
||||
),
|
||||
reviews: count_reviews(repo_full_name, person, args),
|
||||
}
|
||||
end
|
||||
|
||||
@ -211,4 +204,12 @@ module Homebrew
|
||||
|
||||
Utils.safe_popen_read(*cmd).lines.count { |l| l.include?(person) }
|
||||
end
|
||||
|
||||
sig { params(repo_full_name: String, person: String, args: Homebrew::CLI::Args).returns(Integer) }
|
||||
def count_reviews(repo_full_name, person, args)
|
||||
# Users who have made their contributions private are not searchable to determine counts.
|
||||
return 0 if GitHub::API.open_rest("https://api.github.com/users/#{user}/events").empty?
|
||||
|
||||
GitHub.count_issues("", is: "pr", repo: repo_full_name, reviewed_by: person, review: "approved", args: args)
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user