如何获得所有用户补丁的计数?

时间:2019-07-02 11:02:21

标签: gerrit wikimedia

我通过api doc来获取数据。我想获取用户使用用户名进行的所有提交的计数的详细信息。有没有可能的方法来执行它。我尝试搜索许多API,但找不到合适的API。是否有任何API可以获取特定用户的所有提交计数?如果没有,该如何执行?

1 个答案:

答案 0 :(得分:1)

如果您可以访问Gerrit服务器中的Gerrit信息库(GERRIT_SITE / git),则可以在特定的信息库(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
     ...

说明:

--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