commit | 58c7e8411a792653ecb183ef76aff26b79d649c0 | [log] [tgz] |
---|---|---|
author | Claudio Pacchiega <claudio.pacchiega@gmail.com> | Fri Nov 03 17:19:37 2017 +0100 |
committer | Luca Milanesio <luca.milanesio@gmail.com> | Thu Nov 09 07:20:03 2017 +0000 |
tree | ae4577b0e676ffeba8b07f4bd164db901023459c | |
parent | 1b54502f2a5e33e1c6e8f6c709a86075633f0959 [diff] |
Allow statistics of empty commits without files Git allows creating a commit with simply a message and no file changes associated. To avoid our commit statistics to blow up it is needed to protect against reduction of empty files stats. Change-Id: If491eb37e21a0e5d4540a39914943f77177c0f14
Extract commit and review data from Gerrit projects and expose aggregated metrics over REST and SSH API.
To build the analytics plugin you need to have SBT 0.13.x or later installed. If you have a Linux operating system, see the Installing SBT on Linux instructions
Clone the analytics plugin and execute sbt assembly
.
Example:
$ git clone https://gerrit.googlesource.com/plugins/analytics $ cd analytics && sbt assembly
The plugin jar file is created under target/scala-2.11/analytics.jar
Copy the analytics.jar generated onto the Gerrit's /plugins directory.
Nothing to configure, it just works.
Adds new REST API and SSH commands to allow the extraction of repository statistics from Gerrit repositories and changes.
All the API share the same syntax and behaviour. Differently from the standard Gerrit REST API, the JSON collections are returned as individual lines and streamed over the socket I/O. The choice is driven by the fact that the typical consumer of these API is a BigData batch process, typically external to Gerrit and hosted on a separate computing cluster.
A large volume of data can be potentially generated: splitting the output file into separate lines helps the BigData processing in the splitting, shuffling and sorting phase.
Extract a unordered list of project contributors statistics, including the commits data relevant for statistics purposes, such as number of involved files, number of added/deleted lines, timestamp and merge flag.
REST
/projects/{project-name}/analytics~contributors[?since=2006-01-02[15:04:05[.890][-0700]]][&until=2018-01-02[18:01:03[.333][-0700]]]
SSH
analytics contributors {project-name} [--since 2006-01-02[15:04:05[.890][-0700]]] [--until 2018-01-02[18:01:03[.333][-0700]]]
NOTE: Timestamp format is consistent with Gerrit's query syntax, see /Documentation/user-search.html for details.
REST Example:
$ curl http://gerrit.mycompany.com/projects/myproject/analytics~contributors {"name":"John Doe","email":"john.doe@mycompany.com","num_commits":1, "num_files":4,"added_lines":9,"deleted_lines":1, "commits":[{"sha1":"6a1f73738071e299f600017d99f7252d41b96b4b","date":"Apr 28, 2011 5:13:14 AM","merge":false}]} {"name":"Matt Smith","email":"matt.smith@mycompany.com","num_commits":1, "num_files":1,"added_lines":90,"deleted_lines":10,"commits":[{"sha1":"54527e7e3086758a23e3b069f183db6415aca304","date":"Sep 8, 2015 3:11:23 AM","merge":true}]}
SSH Example:
$ ssh -p 29418 admin@gerrit.mycompany.com analytics contributors myproject --since 2017-08-01 --until 2017-12-31 {"name":"John Doe","email":"john.doe@mycompany.com","num_commits":1, "num_files":4,"added_lines":9,"deleted_lines":1, "commits":[{"sha1":"6a1f73738071e299f600017d99f7252d41b96b4b","date":"Apr 28, 2011 5:13:14 AM","merge":false}]} {"name":"Matt Smith","email":"matt.smith@mycompany.com","num_commits":1, "num_files":1,"added_lines":90,"deleted_lines":10,"commits":[{"sha1":"54527e7e3086758a23e3b069f183db6415aca304","date":"Sep 8, 2015 3:11:23 AM","merge":true}]}