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).
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 (title, labels, assignee, milestone)
gc issue edit 42 -t "Updated title"
gc issue edit 42 --add-label bug --add-label docs
gc issue edit 42 --add-assignee @me
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
gc issue delete 42 # Unsupported by GitCode API
# Close / reopen
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 --request-changes |
✅ | ✅ (fallback) |
--json fields |
✅ | ✅ |
-q jq filtering |
✅ | ✅ |
-t template formatting |
✅ | ✅ |
Command aliases (ls → list, new → create) |
✅ | ✅ |
Multi-value options (--label bug --label feature) |
✅ | ✅ |
Known Limitations (GitCode API differences)
- PR comment model: GitCode uses
path + position, not GitHub'sline/side/commit - PR review: GitCode review API differs from GitHub;
--request-changesfalls back to PR comments - Issue deletion:
gc issue deleteis exposed for CLI parity, but GitCode API does not support deleting issues - Issue create/update API: GitCode puts
repoin 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygitcode-0.1.2.tar.gz.
File metadata
- Download URL: pygitcode-0.1.2.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b41b77ddb990304d9206f0cba2f1813620b85f14a9694ad39f1a475d5a13b0f4
|
|
| MD5 |
9976932367d4c90697553bc7d3b1af1c
|
|
| BLAKE2b-256 |
58f5b99eca5898eeef2a0606e94971ce29e29c6c215149f7bc9d495b0be638af
|
Provenance
The following attestation bundles were made for pygitcode-0.1.2.tar.gz:
Publisher:
publish.yml on codeasier/gitcode-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygitcode-0.1.2.tar.gz -
Subject digest:
b41b77ddb990304d9206f0cba2f1813620b85f14a9694ad39f1a475d5a13b0f4 - Sigstore transparency entry: 1438998130
- Sigstore integration time:
-
Permalink:
codeasier/gitcode-cli@3bea8688232ce55aea97cca2a8b52fe4690abcc5 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/codeasier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3bea8688232ce55aea97cca2a8b52fe4690abcc5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pygitcode-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pygitcode-0.1.2-py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e18115b6d24e08088b59ee18f330b5661689d93487d0a9a24c71a62e6dff353e
|
|
| MD5 |
be2b988d982ab779e2e58049f691c214
|
|
| BLAKE2b-256 |
a33216435ca04c62dbf9316366035b8c484a6947bbb228c379097ffa230a6311
|
Provenance
The following attestation bundles were made for pygitcode-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on codeasier/gitcode-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygitcode-0.1.2-py3-none-any.whl -
Subject digest:
e18115b6d24e08088b59ee18f330b5661689d93487d0a9a24c71a62e6dff353e - Sigstore transparency entry: 1438998137
- Sigstore integration time:
-
Permalink:
codeasier/gitcode-cli@3bea8688232ce55aea97cca2a8b52fe4690abcc5 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/codeasier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3bea8688232ce55aea97cca2a8b52fe4690abcc5 -
Trigger Event:
push
-
Statement type: