Skip to main content

A CLI tool for GitCode (api.gitcode.com), modeled after GitHub CLI.

Project description

pygitcode

A CLI tool for GitCode (api.gitcode.com), modeled after GitHub CLI (gh).

PyPI Python License Tests

Installation

pip install pygitcode

This exposes the gc command in your shell.

Quick Start

Authentication

# Login with your GitCode personal access token
gc auth login

# Or set environment variable
export GC_TOKEN=your_token_here

Issues

# List issues (with filtering options)
gc issue list
gc issue list --state closed --author @me
gc issue list --label bug --label "help wanted"
gc issue list --web    # Open in browser

# View an issue (with comments)
gc issue view 42
gc issue view 42 --comments
gc issue view 42 --web

# Create an issue
gc issue create -t "Bug report" -b "Something is broken"
gc issue create --web    # Create in browser

# Edit an issue (add/remove labels, assignees)
gc issue edit 42 -t "Updated title"
gc issue edit 42 --add-label bug --remove-label "in progress"
gc issue edit 42 --add-assignee @me --remove-assignee otheruser

# Comment on an issue
gc issue comment 42 -b "Thanks for the report!"
gc issue comment 42 --editor    # Use system editor

# Close / reopen / delete
gc issue close 42
gc issue reopen 42
gc issue delete 42

Pull Requests

# List PRs (with filtering options)
gc pr list
gc pr list --state merged --author @me
gc pr list --base main --draft
gc pr list --web    # Open in browser

# View a PR (identifier optional - infers from current branch)
gc pr view           # View PR for current branch
gc pr view 42        # By number
gc pr view https://gitcode.com/owner/repo/pulls/42
gc pr view feature-branch

# Create a PR (auto-detects current branch and default base)
gc pr create -t "Add new feature"

# Create with auto-fill from commits
gc pr create --fill              # Use latest commit
gc pr create --fill-first        # Use first commit
gc pr create --fill-verbose      # Use all commits for body

# Create with editor
gc pr create --editor

# Preview without creating
gc pr create --dry-run

# Create in browser
gc pr create --web

# Close / merge / reopen (identifier optional)
gc pr close          # Close PR for current branch
gc pr close 42 -c "Closing as stale"
gc pr close --delete-branch    # Delete remote branch too

gc pr merge          # Merge PR for current branch
gc pr merge 42 -s    # Squash merge
gc pr merge --rebase

# Edit a PR (add/remove labels, assignees, reviewers)
gc pr edit 42 -t "New title"
gc pr edit --add-label bug --remove-label "needs review"
gc pr edit --add-reviewer @me --remove-reviewer otheruser

# Mark as ready or convert to draft
gc pr ready          # Mark current branch's PR as ready
gc pr ready --undo   # Convert back to draft

# Comment / review / diff (identifier optional)
gc pr comment -b "LGTM"
gc pr comment --path src/file.py --position 5 -b "Suggestion"

gc pr review --approve
gc pr review --comment -b "Looks good but needs tests"
gc pr review --request-changes -b "Missing documentation"

gc pr diff           # View diff for current branch's PR
gc pr diff 42

# Checkout a PR (identifier optional)
gc pr checkout        # Checkout PR for current branch? (prompts if ambiguous)
gc pr checkout 42
gc pr checkout -b local-branch-name

Global Options

# Use a different repo without cd-ing into it
gc issue list -R owner/repo
gc pr list -R owner/repo

# Output as JSON with field selection
gc issue list --json number,title,state,author
gc pr list --json number,title,state,head,base

# Filter with jq
gc issue list -q '.[] | select(.state == "open")'
gc pr list -q '.[] | select(.draft == true)'

# Format with Go-style templates
gc issue list -t '{{.number}} {{.title}} ({{.state}})'
gc pr view -t 'PR #{{.number}}: {{.title}}\n{{.body}}'

# Open in browser
gc issue view 42 -w
gc pr view -w

Alignment with gh CLI

pygitcode aims to be as familiar as possible to gh users:

Feature gh gc
PR identifier optional (current branch inference)
--fill / --fill-first / --fill-verbose
--editor
--dry-run
--web (create/view in browser)
--remove-* flags for edit commands
pr ready --undo (convert to draft)
pr review --comment / --request-changes ✅ (fallback)
--json fields
-q jq filtering
-t template formatting
Command aliases (lslist, newcreate)
Multi-value options (--label bug --label feature)

Known Limitations (GitCode API differences)

  • PR comment model: GitCode uses path + position, not GitHub's line/side/commit
  • PR review: GitCode review API differs from GitHub; --comment and --request-changes fall back to PR comments
  • Issue create/update API: GitCode puts repo in request body, not URL path

Development

# Clone
git clone https://github.com/yourusername/pygitcode.git
cd pygitcode

# Install in editable mode with dev dependencies
pip install -e ".[dev]"

# Install pre-commit hooks
pre-commit install

# Run all checks manually
pre-commit run --all-files

# Or run individually
python -m pytest tests/unit/ --cov=gitcode_cli
python -m ruff check src/ tests/
python -m ruff format src/ tests/
python -m basedpyright src/

Roadmap

See ROADMAP.md for planned features and current gaps.

License

MIT

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

pygitcode-0.1.0.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

pygitcode-0.1.0-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pygitcode-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57f0ba58075acf032afea59d3227ecf791271ed2b475eeaa245aa49532480c78
MD5 e6274ea20f7edb625bf10a4f9f295c24
BLAKE2b-256 6ee26aca15f7971990f105fa4ce4ea16d03679667163aa1ed1693b7e53cc2b7c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pygitcode-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for pygitcode-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 169f709927dcf3bef16f9dcc2a57a72bba3d7509f741ae38ffb0d49aacba8bbb
MD5 422bfd6e5d8d923c3187409f5a839c4f
BLAKE2b-256 4469ff4faff4509d6fa2c91b24754c8c94dd2fc0c5f6da7886ca18e8a6ab1b68

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