Skip to main content

Push commits from local repositories to GitLeague

Project description

GitLeague Client

Push commits from your local Git repositories to GitLeague.

Features

  • Push-based synchronization: Your local repository data stays on your machine
  • PAT tokens are local: GitHub/GitLab tokens never leave your computer
  • Batch processing: Efficiently sync multiple repositories and commits
  • Retry logic: Automatic retries with exponential backoff
  • YAML configuration: Simple, readable configuration format
  • Multiple auth methods: SSH, HTTPS with tokens, or public repos
  • Dry-run mode: Preview what would be synced before sending data

Installation

pip install gitleague-client

Or from source:

git clone https://github.com/thegitleague/gitleague-client
cd gitleague-client
pip install -e .

Quick Start

1. Get Your API Key

  1. Log in to GitLeague
  2. Go to Settings → API Keys
  3. Create a new API key
  4. Copy the key (shown only once!)

2. Create Configuration File

Generate a template:

gitleague-client init

This creates repos.yaml. Edit it to add your repositories:

api_url: "https://api.thegitleague.com"
# api_key: "tgl_xxx_yyy"  # Or use GITLEAGUE_API_KEY env var

projects:
  - name: "My Project"
    project_id: "PROJECT_ID"  # From GitLeague web UI
    repos:
      - path: "~/code/my-repo"
        git_url: "git@github.com:user/my-repo.git"
        ssh_key: "~/.ssh/id_ed25519"

3. Test Connection

gitleague-client test --config repos.yaml

4. Sync Commits

# Preview what would be synced
gitleague-client sync --config repos.yaml --dry-run

# Actually sync
gitleague-client sync --config repos.yaml

Configuration

API Key

Set your API key in one of two ways:

# Method 1: In config file (not recommended - don't commit!)
api_key: "tgl_xxxxxxxx_yyyyyyyyyyyyyyyyyyyyyyyyyyyy"
# Method 2: Environment variable (recommended)
export GITLEAGUE_API_KEY="tgl_xxxxxxxx_yyyyyyyyyyyyyyyyyyyyyyyyyyyy"
gitleague-client sync

Authentication Methods

repos:
  # SSH with key
  - path: "~/repo1"
    git_url: "git@github.com:user/repo1.git"
    ssh_key: "~/.ssh/id_ed25519"

  # HTTPS with personal access token
  - path: "~/repo2"
    git_url: "https://github.com/user/repo2.git"
    username: "myuser"
    password_env: "GITHUB_TOKEN"

  # Public repo (no auth)
  - path: "~/repo3"
    git_url: "https://github.com/user/repo3.git"

Settings

api_url: "https://api.thegitleague.com"  # API endpoint
batch_size: 100                           # Commits per request (1-1000)
max_retries: 3                            # Retries on errors

Usage

Sync All Repositories

gitleague-client sync --config repos.yaml

Dry Run (Preview)

gitleague-client sync --config repos.yaml --dry-run

Test API Connection

gitleague-client test --config repos.yaml

Generate Template Config

gitleague-client init --config my-config.yaml

How It Works

  1. Config Loading: Reads YAML configuration with repository paths and credentials
  2. Git Scanning: Extracts commits from local repositories since last sync
  3. Batching: Groups commits into batches (up to 1000)
  4. API Push: Sends commits to GitLeague API via HTTPS
  5. Deduplication: API skips commits that already exist
  6. Status Update: Tracks sync status for resume capability

Data Flow

Local Git Repos
       ↓
Git Scanner (extract commits)
       ↓
API Client (batch & send)
       ↓
GitLeague API (/sync/projects/{id}/repos/{id}/commits)
       ↓
GitLeague Database

Security

  • PAT tokens stay local: Only your API key is sent to GitLeague
  • HTTPS required: All API communication is encrypted
  • API key rotation: You can revoke API keys instantly from the web UI
  • No token storage: Credentials are never saved in the client
  • Audit logging: All syncs are logged on the server

Troubleshooting

"Invalid API key"

  • Check that GITLEAGUE_API_KEY is set correctly
  • Or verify api_key in repos.yaml
  • Regenerate the key from GitLeague web UI if needed

"Repository not found"

  • Verify the repository path exists locally
  • Ensure the project_id matches your GitLeague project
  • Check that the repository is configured as push_client (not pull_celery)

"No new commits"

  • The client uses the last_ingested_sha to find new commits
  • First sync may be slow if repository has many commits
  • You can force a resync from the web UI

SSH Key Issues

  • Ensure SSH agent is running: ssh-add ~/.ssh/id_ed25519
  • Or use HTTPS authentication instead

Development

Install with dev dependencies

pip install -e ".[dev]"

Run tests

pytest tests/

Code quality

black gitleague_client/
ruff check gitleague_client/
mypy gitleague_client/

Architecture

gitleague_client/
├── __init__.py           # Package metadata
├── exceptions.py         # Custom exceptions
├── config.py            # YAML config loading & validation
├── git_scanner.py       # Git repository scanning
├── api_client.py        # API client with retry logic
├── sync.py              # Sync orchestration
└── cli.py               # CLI entry point

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Run code quality checks
  5. Submit a pull request

License

MIT - See LICENSE file

Support

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

gitleague_client-0.1.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

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

gitleague_client-0.1.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file gitleague_client-0.1.0.tar.gz.

File metadata

  • Download URL: gitleague_client-0.1.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for gitleague_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8903d11d1b27bcb215d6e4049ba0ae8869148bf7520d966f074dd4f443d84788
MD5 74eb67ae5b9a613063f929e145919c8d
BLAKE2b-256 09ac6bcc73c68d2767e2d63e2b12f43b33dd2f2d6648ea2ff94a5d4a870283b3

See more details on using hashes here.

File details

Details for the file gitleague_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gitleague_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 108ede116913d7cc35652e6382b55dd4176c3a9e7076ee6319bc01c1ff454590
MD5 15190382615dbde1bcaed72c523e4144
BLAKE2b-256 57d1ea042a4f38dfa9f8d72e3a212ff2bcbf3393b6580ff2889199752fb40d2a

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