GitXplorerGitXplorer
d

mongo-gerrit

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
b6b1598b724d24c3424336a8d26239e4febd4309

Ignore query options related to files

ddpursehouse committed 8 years ago
Unverified
66f150c9284c75abb9f6b0aecbcdb4a0bf944d00

Fail gracefully when unable to configure Gerrit API

ddpursehouse committed 8 years ago
Unverified
99d33fde4ae28bd5606a3eff883f52246248ee84

More improvements in the configuration documentation

ddpursehouse committed 8 years ago
Unverified
fedbd6f05c60fafad6f0531a7ffe4f6bf804f60f

Make the default query configurable

ddpursehouse committed 8 years ago
Unverified
a8f58e93919d9738ad7ade60bac4c9a485db32ec

Minor doc fixes

ddpursehouse committed 8 years ago
Unverified
0864fbe22449b6518e46a53913d24efb77e40b8d

Allow to configure query batch size globally or per site

ddpursehouse committed 8 years ago

README

The README file for this repository.

mongo-gerrit

mongo-gerrit is a Python library to sync review data from a Gerrit Code Review server to a local MongoDB database.

Prerequisites and environment

mongo-gerrit has been developed on OSX with Python 2.7. It should also work on other platforms, but has not been tested. Python 3 is not supported.

It is assumed that a MongoDB instance is running. If it's not running on the default host and port (localhost:27017), this can be specified.

Installation

mongo-gerrit is not distributed as a package. To install it, clone the source code from the Github repository.

After cloning the source code, set up a virtual environment and install the dependencies:

$ cd mongo-gerrit
$ virtualenv ENV
$ source ./ENV/bin/activate
(ENV) $ pip install -r requirements.txt

Configuration

Configuration is done in a YAML file named mongo-gerrit.yml which may be located either in the user's home folder or in the current directory.

The mongo-gerrit.yml file included in the repository defines configurations for gerrit-review and android-review and default global settings with reasonable values (as arbitrarily decided by the author).

Global settings

Global settings are configured under the settings section.

settings:
 query-options:
   - OPTION_NAME
   - OPTION_NAME
   - ...
 query-batch-size: 1000
 default-query: "age:1day"

All global settings may be overridden per server in the sites section (described below).

Gerrit server settings

Settings for individual Gerrit servers are configured in blocks under the sites section.

sites:
 site-name:
   url: https://example.com/review/
   auth: basic
   query-options:
     - OPTION_NAME
     - OPTION_NAME
   query-batch-size: 300
   default-query: "owner:self"
  • site-name: Unique identifier for this site. This will be used as the database name in MongoDb.
  • url: Required. The fully qualified URL to the Gerrit server.
  • auth: Optional. Authentication type. May be digest or basic. Defaults to digest if not specified.

Usage

To sync review data from the site identified as gerrit-review:

(ENV) $ python sync.py gerrit-review

On the first run all changes found by the default query are fetched. This may take a long time if the query results in a large number of changes.

On subsequent runs, only the changes that have been updated since the previous sync will be fetched.

By default mongo-gerrit connects to MongoDB on the default hostname and port (localhost:27017). Use --database-hostname and --database-port to use a different location.

Limitations, known problems, TODOs

  • It's not possible to provide arbitrary queries to limit the results that are returned.

  • It's not possible to force re-sync of changes. Changes will only be re-synched if they are updated in Gerrit after the previous sync.