A lightweight command-line tool for interacting with Gerrit Code Review, written in Rust.
- 📖 Read comments from Gerrit changes
- ✍️ Post comments to trigger builds or leave reviews
- 📊 View diffs for patchsets
- 🔐 Secure credential storage via
~/.gerritrc - 🎯 Auto-detect Change-Id from git commits
- ⚡ Fast shortcuts (
rc,wc) for common commands
- Rust (1.70+)
- Git
- Access to a Gerrit instance
# Clone or navigate to the repository
cd /path/to/gcli
# Install system-wide
cargo install --path .
# Verify installation
gcli --helpThe binary will be installed to ~/.cargo/bin/gcli, which should be in your PATH.
To update to the latest version:
cd /path/to/gcli
git pull # if using git
cargo install --path . --forceCreate a ~/.gerritrc file with your Gerrit credentials:
url = "https://gerrit.example.com"
username = "your_username"
password = "your_http_password"Important: Set secure permissions:
chmod 600 ~/.gerritrc- Log in to your Gerrit instance
- Go to Settings → HTTP Credentials
- Generate or copy your HTTP password (not your regular password)
# Read comments for a specific change
gcli read-comments 12345
gcli rc 12345 # shortcut
# Auto-detect from current git commit
gcli rc# Post a comment
gcli comment "Looks good to me!" -c 12345
gcli wc "LGTM" -c 12345 # shortcut
# Post to current commit (auto-detected)
gcli wc "Approved"
# Trigger Jenkins builds
gcli wc "__TRIGGER_CANVAS_LMS__"# View diff for a specific change
gcli diff 12345
# Auto-detect from current git commit
gcli diff
# Specific revision/patchset
gcli diff 12345 -r 3| Command | Shortcut | Description |
|---|---|---|
read-comments [CHANGE_ID] |
rc |
Fetch all comments for a change |
comment <MESSAGE> |
wc |
Post a comment/review message |
diff [CHANGE_ID] |
- | Download code changes (diff) |
All commands support:
-c, --change-id <ID>- Specify change ID (optional if in git repo)-r, --revision <NUM>- Specific revision/patchset (default: "current")
Global options:
-s, --url <URL>- Override Gerrit URL-u, --username <USER>- Override username-p, --password <PASS>- Override password
# Read comments from current commit
gcli rc
# Post approval comment
gcli wc "Ship it!" -c 12345
# View what changed in patchset 2
gcli diff 12345 -r 2
# Use different Gerrit server
gcli -s https://other-gerrit.com rc 12345If you don't provide a CHANGE_ID, gcli will:
- Read your current git commit message
- Extract the
Change-Id: I...line - Use that for the Gerrit API call
gcli uses HTTP Basic Auth with your Gerrit HTTP password (from ~/.gerritrc). This is the same authentication method used by git when pushing to Gerrit.
Make sure your commit has a Change-Id: line. If using Gerrit's commit-msg hook, this should be added automatically.
Either:
- Create
~/.gerritrcwith your credentials - Pass credentials via flags:
gcli -s <url> -u <user> -p <pass> <command>
Check:
- Your Gerrit URL is correct
- Your HTTP password is valid (not your login password)
- You have network access to the Gerrit server
Built with:
MIT