This project provides tools to display statistics from a Gerrit repository. It generates output in HTML, CSV and plaintext formats.
The tool can be useful for analysing how efficiently code reviews are implemented in an organization, and how often cross-team code reviews are conducted.
There are two separate tools:
- GerritDownloader, which downloads JSON data from the server
- GerritStats, which parses the json output provided by GerritDownloader.
./gradlew assemble
./gerrit_downloader.sh
Lists all command line options for the data download tool.
./gerrit_stats.sh
Lists all command line options for the statistics generator.
Fetching data from Gerrit can take a while. Use GerritDownloader to get the JSON output from the server so that you can parse it later:
./gerrit_downloader.sh --server gerrit.instance.on.inter.nets --project YourProjectName --limit 7500 --output-dir gerrit_out/
The above command will download all data from the given Gerrit server and given project, and store the data in .json format in the given output directory.
If you have multiple projects in Gerrit and want to take a look at all the data, omit the --project argument. This will download data for all projects you have access to:
./gerrit_downloader.sh --server gerrit.instance.on.inter.nets --output-dir gerrit_out/
Once you have the data, you can start to play around with the output. You can e.g. include only a particular set of developers, which can be useful when looking at e.g. team-level review practices.
./gerrit_stats.sh --file ./GerritStats/gerrit-json-out.txt --branches master --include [email protected],[email protected],[email protected],[email protected] --output-type plain
The above command will give you output as illustrated below:
[email protected]
Commits: 1072
Comments written: 748
Comments received: 444
Commit/comment ratio: 0.41417912
Added as reviewer: 1939
Review comment ratio: 0.38576585
Avg. patch set count: 1.4906716
Max patch set count: 11
+2 reviews given: 944
+1 reviews given: 1115
-1 reviews given: 285
-2 reviews given: 111
# of people added as reviewers: 26
Adds them as reviewers: [email protected] (900), [email protected] (875), [email protected] (1)
They add this person as reviewer: [email protected] (300), [email protected] (217), [email protected] (1)
If you want to do some processing on the data with Excel or similar tools, a CSV format might be convenient for import.
./gerrit_stats.sh --file gerrit-json-out.txt --branches master --include [email protected],[email protected],[email protected] --output-type csv
The output of the command looks like this:
Project: all data from file /Users/holmsted/dev/GerritStats/out.txt
Branches: master
From: 2014-10-23
To: 2015-08-21
Identity Commits Comments written Comments received Commit/comment ratio Added as reviewer Review comment ratio Avg. patch set count Max patch set count +2 reviews given +1 reviews given -1 reviews given -2 reviews given # of people added as reviewers
[email protected] 80 1 14 0.175000 335 0.002985 1.487500 8 35 100 5 1 18
[email protected] 8 4 2 0.250000 167 0.023952 1.250000 3 23 23 6 0 6
[email protected] 50 8 7 0.140000 366 0.021858 1.760000 5 101 77 7 9 11
[email protected] 276 19 57 0.206522 1377 0.013798 2.246377 13 174 225 17 8 27
[email protected] 1293 328 257 0.198763 2537 0.129287 1.486466 11 1231 1330 384 136 26
The default output of the tool is HTML.
This will generate a set of HTML files that include graphs and charts, such as a proximity graph of the developers, based on how many review comments they write to each other, as well as a per-developer page that lists all their review comments and links back to the reviews.
./gerrit_stats.sh --file gerrit-json-out.txt --branches master --include [email protected],[email protected],[email protected] --list-commits-exceeding-patch-set-count 5
However, you don't need all the arguments to generate output. Just pass the directory with downloaded json data to -f, and you're ready to go:
./gerrit_stats.sh --f gerrit_out/
The index page will provide you with a sortable overview table of some of the core statistics, similar to the plaintext CSV output.
The index page also contais a graph that illustrates how developers are connected to each other:
And on the per-person page, you'll see a chart of review comments per day, a configurable list of commits that have a high number of patch sets, et cetera: