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

dev-cmd/contributions: Fix single-user handling; be more verbose #14767

Merged
merged 2 commits into from Feb 22, 2023
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
19 changes: 11 additions & 8 deletions Library/Homebrew/dev-cmd/contributions.rb
Expand Up @@ -58,7 +58,15 @@ def contributions
args.repositories
end

return ofail "CSVs not yet supported for the full list of maintainers at once." if args.csv? && args.user.nil?
if args.user
user = args.user
results[user] = scan_repositories(repos, user, args)
puts "#{user} contributed #{total(results[user])} times #{time_period(args)}."
puts generate_csv(T.must(user), results[user]) if args.csv?
return
end

odie "CSVs not yet supported for the full list of maintainers at once." if args.csv?

maintainers = GitHub.members_by_team("Homebrew", "maintainers")
maintainers.each do |username, _|
Expand All @@ -71,13 +79,6 @@ def contributions
results[username] = scan_repositories(repos, username, args)
puts "#{username} contributed #{total(results[username])} times #{time_period(args)}."
end

return unless args.user

user = args.user
results[user] = scan_repositories(repos, user, args)
puts "#{user} contributed #{total(results[user])} times #{time_period(args)}."
puts generate_csv(T.must(user), results[user]) if args.csv?
end

sig { params(repo: String).returns(Pathname) }
Expand Down Expand Up @@ -139,6 +140,8 @@ def scan_repositories(repos, person, args)
tap.full_name
end

puts "Determining contributions for #{person} on #{repo_full_name}..." if args.verbose?

data[repo] = {
commits: GitHub.repo_commit_count_for_user(repo_full_name, person),
coauthorships: git_log_trailers_cmd(T.must(repo_path), "Co-authored-by", person, args),
Expand Down