Cross-platform Git history access via Rust with a Python API
Project description
Cross-platform Git history access implemented in Rust with a Python API via PyO3 and libgit2.
Highlights
- Fast Git history access via libgit2 with a lightweight Python wrapper.
- Repo helpers for HEAD info, revision parsing, commit listing, and branch/tag lookup.
- History rewriting tools: amend messages, rewrite author/committer, reword arbitrary commits, squash, rebase (pick-only), drop commits, and purge paths.
- All rewrites return a
RewriteResultwith mappings and ref updates.
Install
pip install pygitx
Python usage
import pygitx
from pathlib import Path
repo = pygitx.open_repo(Path("."))
head = repo.head()
print("HEAD:", head.id if head else "None")
# Resolve a revision (branch/tag/oid) to a hex id
print("main ->", repo.rev_parse("main"))
for c in repo.list_commits(max=5):
print(f"{c.id[:7]} {c.author} <{c.email}> {c.summary}")
# Quick repo summary (also printed by str(repo))
print(repo.summary())
# Graph helpers
print("Branches:", repo.list_branches(local=True, remote=False))
print("Tags:", repo.list_tags())
print("Current branch:", repo.current_branch())
print("Merge base of main and feature:", repo.merge_base("main", "feature"))
print("Ahead/behind main vs feature:", repo.ahead_behind("main", "feature"))
print("Diff HEAD~1..HEAD:", repo.diff_stat("HEAD~1", "HEAD").files_changed, "files")
Example script: examples/demo.py (run with --help to see options).
Documentation
Full API and usage docs live in docs/ (Sphinx). Build locally with:
make docs
Or browse the published docs if available in your environment.
Development
- Run Rust and Python checks:
make test - Pytest for Python wrappers:
pytest - Make targets:
make venv,make install,make develop,make release,make docs,make test - Optional pre-commit prompt: set
git config core.hooksPath .githooksandchmod +x .githooks/pre-committo be prompted to runmake develop,make test, andpytestbefore each commit.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 pygitx-0.2.1-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: pygitx-0.2.1-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 1.4 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cc93fc9fed6b73c5be7cad3efeec52310f83d5543677855bb94d7f6b407aba9
|
|
| MD5 |
000d2263630aa3bfcbc69eda4c7b8762
|
|
| BLAKE2b-256 |
1ec3eea40ef5836aaabf471aaef10285dc5ddb27516d55e1e2aec6422c87d006
|
Provenance
The following attestation bundles were made for pygitx-0.2.1-cp39-abi3-win_amd64.whl:
Publisher:
publish-to-pypi.yml on zangjiucheng/pygitx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygitx-0.2.1-cp39-abi3-win_amd64.whl -
Subject digest:
0cc93fc9fed6b73c5be7cad3efeec52310f83d5543677855bb94d7f6b407aba9 - Sigstore transparency entry: 798523249
- Sigstore integration time:
-
Permalink:
zangjiucheng/pygitx@95752e7ade6b8f4cf309538ac343a2b55782b87c -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/zangjiucheng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@95752e7ade6b8f4cf309538ac343a2b55782b87c -
Trigger Event:
push
-
Statement type:
File details
Details for the file pygitx-0.2.1-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: pygitx-0.2.1-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
728565abe86ac5ad8dac4056e585a0c05df372ccb611a8aa904ccab202a9328d
|
|
| MD5 |
6458fd677b12d54eed0f45f105dd3245
|
|
| BLAKE2b-256 |
700394227f2d8bcff74740fd21c63ad6efef30ca135c343553e951152d6f427f
|
Provenance
The following attestation bundles were made for pygitx-0.2.1-cp39-abi3-manylinux_2_34_x86_64.whl:
Publisher:
publish-to-pypi.yml on zangjiucheng/pygitx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygitx-0.2.1-cp39-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
728565abe86ac5ad8dac4056e585a0c05df372ccb611a8aa904ccab202a9328d - Sigstore transparency entry: 798523255
- Sigstore integration time:
-
Permalink:
zangjiucheng/pygitx@95752e7ade6b8f4cf309538ac343a2b55782b87c -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/zangjiucheng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@95752e7ade6b8f4cf309538ac343a2b55782b87c -
Trigger Event:
push
-
Statement type:
File details
Details for the file pygitx-0.2.1-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: pygitx-0.2.1-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
278bb98cd2f0105f1543fc2a47133ea3405a8e5e3bfce6d08b39958f453ade4c
|
|
| MD5 |
98de59c6e7cd633f15018971bf0601d6
|
|
| BLAKE2b-256 |
a26aec7ea3877135e332a7ca7e427893ef7105f146f161919ff30cee2f36324a
|
Provenance
The following attestation bundles were made for pygitx-0.2.1-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
publish-to-pypi.yml on zangjiucheng/pygitx
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygitx-0.2.1-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
278bb98cd2f0105f1543fc2a47133ea3405a8e5e3bfce6d08b39958f453ade4c - Sigstore transparency entry: 798523240
- Sigstore integration time:
-
Permalink:
zangjiucheng/pygitx@95752e7ade6b8f4cf309538ac343a2b55782b87c -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/zangjiucheng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@95752e7ade6b8f4cf309538ac343a2b55782b87c -
Trigger Event:
push
-
Statement type: