dev-cmd/contributions: Add a per-repo total column to the CSV

```
$ brew contributions issyl0 --csv
The user issyl0 has made 1202 contributions in all time.
user,repo,commits,coauthorships,signoffs,total
issyl0,brew,332,13,0,345
issyl0,core,473,24,326,823
issyl0,cask,4,0,0,4
issyl0,aliases,0,0,0,0
issyl0,autoupdate,1,0,0,1
issyl0,bundle,14,2,0,16
issyl0,command-not-found,1,0,0,1
issyl0,test-bot,3,0,0,3
issyl0,services,9,0,0,9
issyl0,cask-drivers,0,0,0,0
issyl0,cask-fonts,0,0,0,0
issyl0,cask-versions,0,0,0,0
```
This commit is contained in:
Issy Long 2023-02-15 13:56:37 +00:00
parent 2719c345ab
commit 9aad9d011b
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -96,9 +96,16 @@ module Homebrew
sig { params(user: String, results: Hash).returns(String) }
def generate_csv(user, results)
CSV.generate do |csv|
csv << %w[user repo commits coauthorships signoffs]
csv << %w[user repo commits coauthorships signoffs total]
results.each do |repo, counts|
csv << [user, repo, counts[:commits], counts[:coauthorships], counts[:signoffs]]
csv << [
user,
repo,
counts[:commits],
counts[:coauthorships],
counts[:signoffs],
counts.values.sum
]
end
end
end