Skip to main content

A command-line tool to post review labels to Gerrit changes

Project description

gerrit-review

A command-line tool to post review labels to Gerrit changes.

This tool can be used to set labels (for example, Jira-Review or Code-Review) on one or more Gerrit change IDs. It also supports fetching and operating on related changes and changes within a topic.

Requirements

  • Python 3.8+
  • Network access to your Gerrit server with HTTP authentication configured

Installation

From PyPI (recommended)

pip install gerrit-review

From source

git clone https://github.com/XuNeo/gerrit-review.git
cd gerrit-review
pip install -e .

Standalone script (legacy)

You can also download and run the standalone script directly:

chmod +x gerrit-review
gerrit-review --help

Usage

Basic usage:

gerrit-review [options] [change-id ...]

Options

  • --label <name> : The label name to post (e.g. Jira-Review, Code-Review). Default: Code-Review
  • --value <num> : The value to post for the label (e.g. 1, -1, 2). Default: 1
  • --url <url> : Gerrit base URL. Default: https://gerrit.pt.mioffice.cn/
  • --user <username>, -u : Gerrit username (or set GERRIT_USER environment variable)
  • --password <password>, -p : Gerrit HTTP password (or set GERRIT_PASSWORD environment variable)
  • --topic <name>, -t : Fetch all changes with the specified topic name
  • --related : Fetch related changes (dependency chain) for each change
  • --dry-run : Do not post changes, only print what would be done
  • --message <text> : Review message to include

Arguments

  • change-id ... : One or more Gerrit change numeric IDs. Not required if --topic is used.

Authentication

Credentials can be provided via command-line arguments or environment variables:

# Using command-line arguments
gerrit-review --user myuser --password mypass --label Jira-Review --value 1 6197799

# Using environment variables
export GERRIT_USER=myuser
export GERRIT_PASSWORD=mypass
gerrit-review --label Jira-Review --value 1 6197799

Command-line arguments take precedence over environment variables.

Examples

Example 1: Review specific changes

Post a label to one or more changes:

gerrit-review --label Jira-Review --value 1 6197799 6197798

Example 2: Review changes with their dependencies

Fetch related changes (dependency chain) and post the label to all:

gerrit-review --label Jira-Review --value 1 6197799 --related

Output:

🔍 Fetching related changes for 6197799 ...
Found 2 change(s):
  - 6197798
  - 6197799

✅ Posted Jira-Review=1 to 6197798
✅ Posted Jira-Review=1 to 6197799

Example 3: Review all changes in a topic

Fetch all changes with a specific topic and post the label:

gerrit-review --topic "my-feature" --label Jira-Review --value 1

Example 4: Review topic changes with their dependencies

Fetch all changes in a topic, then fetch their related changes (dependency chains), and post the label to all:

gerrit-review --topic "my-feature" --related --label Jira-Review --value 1

Output:

🔍 Fetching changes with topic 'my-feature' ...
🔍 Fetching related changes for 6181520 ...
🔍 Fetching related changes for 6181521 ...
Found 5 change(s):
  - 6181519
  - 6181520
  - 6181521
  - 6181522
  - 6181523

✅ Posted Jira-Review=1 to 6181519
✅ Posted Jira-Review=1 to 6181520
...

Example 5: Dry run

Preview what would be done without actually posting:

gerrit-review --topic "my-feature" --related --label Jira-Review --value 1 --dry-run

Notes

  • This script uses Gerrit's REST API and requires HTTP authentication
  • The --related flag fetches changes in the dependency chain (parent/child commits)
  • The --topic flag queries all changes tagged with the specified topic
  • When both topic and related are used, the script first fetches all changes in the topic, then expands to include their dependency chains
  • Results are automatically deduplicated when multiple changes reference the same dependencies

Contributing

Contributions, fixes, and documentation improvements are welcome. Open an issue or submit a pull request with changes.

License

This project is licensed under the MIT License — see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gerrit_review-0.1.0a0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gerrit_review-0.1.0a0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file gerrit_review-0.1.0a0.tar.gz.

File metadata

  • Download URL: gerrit_review-0.1.0a0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.14

File hashes

Hashes for gerrit_review-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 a1543dabc16e1915e44bec7fac4388114562ba0d8338614451d76b106c011f60
MD5 49396defe97a4d1da60ccbd790c11722
BLAKE2b-256 6fe53d4222368a6fa4477a0fdf3391d4352d27898edee1dfdf6fd84cb1b3a5fc

See more details on using hashes here.

File details

Details for the file gerrit_review-0.1.0a0-py3-none-any.whl.

File metadata

File hashes

Hashes for gerrit_review-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea7a2a66450120f4f57278d7ed31432d6385b67aef07b496ee7f3231963b9090
MD5 302493f490bd165eb2018102ced8541d
BLAKE2b-256 bbb337baaaf64a89f27a2079f10b7a0282a8101aed06a2ca191740ecae4c1414

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page