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?
Asked
Active
Viewed 278 times
1 Answers
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

Marcelo Ávila de Oliveira
- 19,950
- 3
- 39
- 50
-
Is it not possible with the api (instead of using ```git```)? – Sandesh Ghanta Jul 03 '19 at 04:48
-
It is possible but It will be very much difficult to achieve. – Marcelo Ávila de Oliveira Jul 03 '19 at 20:00
-
I have searched most of their docs but could not find any api's to perform it. If there is a way to get the count, can you please tell me how to perform it? – Sandesh Ghanta Jul 04 '19 at 06:26
-
1You'll need to query for changes (https://gerrit.wikimedia.org/r/Documentation/rest-api-changes.html#list-changes) and then process the result to find out who is the owner of the change to sum up the total. – Marcelo Ávila de Oliveira Jul 04 '19 at 16:47
-
Is it possible to get the commits only after a specific create date? – Sandesh Ghanta Jul 11 '19 at 09:07
-
No, it's not possible. – Marcelo Ávila de Oliveira Jul 12 '19 at 12:24
-
Is there any possible way to get all the user changesets for a specific span (based on created date of the changesent) in gerrit? – Sandesh Ghanta Jul 13 '19 at 09:32
-
I don't think so. You'll need to get all changes from the user and then, locally, process only the changes in the specific span. – Marcelo Ávila de Oliveira Jul 15 '19 at 17:50