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

Installation

pip install pygitcode

This exposes the gc (or gitcode) command in your shell.

Windows PowerShell Users

On Windows PowerShell, gc is a built-in alias for the Get-Content cmdlet, which shadows the GitCode CLI. Use gitcode instead:

gitcode auth login
gitcode issue list
gitcode pr list

Alternatively, you can remove or override the alias in your PowerShell profile:

# Remove for the current session
Remove-Item Alias:gc -Force

# Or persist the override in your profile
Set-Alias -Name gc -Value 'C:\Users\<user>\AppData\Roaming\Python\Python313\Scripts\gc.exe'

Quick Start

Authentication

# Login with your GitCode personal access token
gc auth login

# Check auth status
gc auth status

# Print the current auth token
gc auth token

# Logout
gc auth logout

# 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 --label bug --label "help wanted"   # Multiple labels
gc issue create --web    # Create in browser

# Edit an issue (add/remove labels, assignees, milestones)
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
gc issue edit 42 --milestone v1.0 --remove-milestone

# 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 close 42 -c "Fixed in #50" --reason completed

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 42 --comments   # Include comments
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
gc pr merge --delete-branch    # Delete remote branch after merge

# Edit a PR (add/remove labels, assignees, reviewers, milestones)
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
gc pr edit --milestone v1.0 --remove-milestone

# 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 comment --body-file comment.txt
gc pr comment --editor

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.2a0.tar.gz (20.5 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.2a0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file pygitcode-0.1.2a0.tar.gz.

File metadata

  • Download URL: pygitcode-0.1.2a0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pygitcode-0.1.2a0.tar.gz
Algorithm Hash digest
SHA256 b29d82e5e3a5472c9c571b2b71a395a63236ad3b19d0969c4e22bcfa30ff4c73
MD5 d9ac379e320109b1c4487cfaef3b4cf9
BLAKE2b-256 3c4652edfe876cae47902875660f207049830654191b6b10608cec04314c6741

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygitcode-0.1.2a0.tar.gz:

Publisher: publish.yml on codeasier/gitcode-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygitcode-0.1.2a0-py3-none-any.whl.

File metadata

  • Download URL: pygitcode-0.1.2a0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pygitcode-0.1.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 b36bcab2f121acbf1afb93754cda5d4d2eb5575d4e02ea10c4c1e5a69fa8d67b
MD5 59c70c81ab09da090c91e2cb8c2e4453
BLAKE2b-256 a03d5ad65f93a752994fe6bf4fa3360669005bc966bfa1176a83b549f6fe2ac2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygitcode-0.1.2a0-py3-none-any.whl:

Publisher: publish.yml on codeasier/gitcode-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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