Skip to main content

CLI tool and Python API wrapper for Gerrit Code Review

Project description

PyPI Build Status Documentation Status Python Version

python-gerritclient

CLI tool and Python API wrapper for Gerrit Code Review

Requirements

Python 3.11+ is required. This project uses modern Python features and tooling.

Quick Start

Command Line Tool (Recommended: Using UV)

UV is a fast, modern Python package manager. Recommended for the best experience.

  1. Install UV (if not already installed):

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. Clone the repository:

    git clone https://github.com/tivaliy/python-gerritclient.git
    cd python-gerritclient
    
  3. Configure environment variables (create a .env file or export directly):

    # Option A: Create a .env file
    cp .env.example .env
    # Edit .env with your settings
    
    # Option B: Export directly
    export GERRIT_URL=https://review.example.com
    export GERRIT_AUTH_TYPE=basic
    export GERRIT_USERNAME=admin
    export GERRIT_PASSWORD="your-http-password"
    
    • GERRIT_URL - Gerrit server URL (e.g., https://review.openstack.org)
    • GERRIT_AUTH_TYPE - HTTP authentication scheme (basic or digest), omit for anonymous access
    • GERRIT_USERNAME and GERRIT_PASSWORD - user credentials from Gerrit (Settings → HTTP Password)
  4. Install dependencies and run:

    uv sync
    uv run gerrit --help
    
  5. Run commands:

    uv run gerrit plugin list
    uv run gerrit account list "john"
    

Command Line Tool (Alternative: Using pip)

  1. Clone the repository:

    git clone https://github.com/tivaliy/python-gerritclient.git
    cd python-gerritclient
    
  2. Configure environment variables (same as step 3 above)

  3. Install with pip:

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    pip install -e .
    
  4. Run commands:

    gerrit --help
    gerrit plugin list
    

Library Usage

Install the package:

# With UV
uv add python-gerritclient

# With pip
pip install python-gerritclient
from gerritclient import client

connection = client.connect("review.openstack.org", auth_type="digest" username="user-name", password="password")
group_client = client.get_client('group', connection=connection)
members = group_client.get_group_members('swift-core')  # or get_group_members(24)
print(', '.join(member['name'] for member in members))

Output result: Alistair Coles, Christian Schwede, Clay Gerrard, Darrell Bishop, David Goetz, Greg Lange, Janie Richling, John Dickinson, Kota Tsuyuzaki, Mahati Chamarthy, Matthew Oliver, Michael Barton, Pete Zaitcev, Samuel Merritt, Thiago da Silva, Tim Burke

What's New in v1.0

Major modernization release! This version brings python-gerritclient into the modern Python ecosystem:

🚀 Performance & Tooling

  • UV Package Manager: 10-100x faster dependency resolution and installation
  • Ruff Linting: 100x faster than flake8, instant code quality checks
  • Modern Python: Requires Python 3.11+ (dropped Python 2.7/3.5/3.6 support)

🏗️ Infrastructure

  • GitHub Actions CI/CD: Replaced Travis CI with modern GitHub Actions
  • Modern pyproject.toml: Migrated from legacy setup.py/setup.cfg
  • Setuptools Build Backend: Replaced pbr with modern setuptools

✨ Code Quality

  • Removed all Python 2 compatibility code (six library)
  • Applied 100+ code modernizations (modern super(), f-strings, etc.)
  • 96.7% test coverage (178/184 tests passing)

✅ Validated

Tested and working against Gerrit 3.13.1 (latest) on production instances (Android Code Review).

Compatibility

Gerrit Versions

  • Recommended: Gerrit 3.11+ (latest tested: 3.13.1)
  • Supported: Gerrit 2.14+ (backwards compatible)
  • API Coverage: ~45% of Gerrit REST API

Python Versions

  • Required: Python 3.11+
  • Tested: Python 3.11, 3.12, 3.13
  • Dropped: Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10

Development

Setting Up Development Environment

  1. Install UV (recommended):

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. Clone and setup:

    git clone https://github.com/tivaliy/python-gerritclient.git
    cd python-gerritclient
    uv sync --all-extras
    
  3. Install in editable mode:

    uv pip install -e .
    

Running Tests

# Run unit tests with stestr
uv pip install stestr
uv run stestr run

# Run linting
uv run ruff check .

# Run formatting
uv run ruff format .

# Format check (CI)
uv run ruff format --check .

Code Quality Tools

  • Linter: Ruff - Fast Python linter
  • Formatter: Ruff format - Fast Python formatter
  • Test Runner: stestr - Parallel test runner
  • CI/CD: GitHub Actions

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting: uv run stestr run && uv run ruff check .
  5. Format code: uv run ruff format .
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

License

Apache License 2.0

Credits

Originally created by Vitalii Kulanov

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

python_gerritclient-1.2.0.tar.gz (136.2 kB view details)

Uploaded Source

Built Distribution

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

python_gerritclient-1.2.0-py3-none-any.whl (82.8 kB view details)

Uploaded Python 3

File details

Details for the file python_gerritclient-1.2.0.tar.gz.

File metadata

  • Download URL: python_gerritclient-1.2.0.tar.gz
  • Upload date:
  • Size: 136.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_gerritclient-1.2.0.tar.gz
Algorithm Hash digest
SHA256 0217cb541d10bf6d604b206ab1bee8f765c823f8d8d2d6af2cfb99acf7d62071
MD5 acf4a5c0acc5bb529cf0df8c7d32e00f
BLAKE2b-256 acd8e3ed52e8c8a3a4e951be19c892990cfdeab085abcbe75f351a0d1926ffa8

See more details on using hashes here.

File details

Details for the file python_gerritclient-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: python_gerritclient-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 82.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for python_gerritclient-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a9dacbf2c4ec1cabc3c0ccf6532647ae4764c79df4f758fe5f1c31d088f51d8
MD5 27f411e10d00e87bc73f8180cb48f04c
BLAKE2b-256 e6a6596808a2b460356437a1078d709b8bd77b2e7397809031b2864ad3768f5e

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