1

I went through the api doc to get the data from it. I want to get the details of count of all the commits that a user made with the username. Is there any possible way to perform it. I tried searching many of the API's but I could not find a suitable one. Is there any API to get the count of all commits of a specific user? if not then how to perform it?

Sandesh Ghanta
  • 385
  • 2
  • 4
  • 16

1 Answers1

2

If you have access to the Gerrit repositories in the Gerrit server (GERRIT_SITE/git) you can get what you want executing the following command inside an specific repository (GERRIT_SITE/git/REPO_FULL_PATH):

git log --pretty="format:%ae" --since="2019-01-01 00:00:00" --until="2019-12-31 23:59:59" --all | cut -d '@' -f 1 | sort | uniq -c | sort -k 1,1nr -k 2,2
    410 aaaaa
    169 bbbbb
    128 ccccc
     22 ddddd
     19 eeeee
     ...

Explanation:

--pretty="format:%ae" => Show only the committer e-mail
--since and --utill   => Limit the search
cut -d '@' -f 1       => Remove the "@DOMAIN" from the e-mail address
sort                  => Sort by user name
uniq -c               => Omit repeated user names, prefixing users by the number of occurrences
sort -k 1,1nr -k 2,2  => Sort by number of occurrences then by user name