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 setGERRIT_USERenvironment variable)--password <password>,-p: Gerrit HTTP password (or setGERRIT_PASSWORDenvironment 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--topicis 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
--relatedflag fetches changes in the dependency chain (parent/child commits) - The
--topicflag 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.
Metadata
Release files for gerrit-review 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gerrit_review-0.1.0.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gerrit_review-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.0 kB
Release files / gerrit_review-0.1.0.tar.gz
| Download URL | gerrit_review-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c946a15522d4dce068defa379ee99f032ae10a781176023388c51a9b5e0c4b32
|
|
BLAKE2b-256 checksum How to use checksums |
d7d66849cd518a36716bffe44038c77f2485e7e3c5bef368ab89800a750df9de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / gerrit_review-0.1.0-py3-none-any.whl
| Download URL | gerrit_review-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a39b114e94d64489f534a60df978ae972498f7da106f9d6ff882dc3a5fb39875
|
|
BLAKE2b-256 checksum How to use checksums |
aaf2f238f6e0473ad7934b3d91ee2398c60287159a36c82036a6966ffdfbf9e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|