Skip to main content

Cross-platform Git history access via Rust with a Python API

Project description

PyGitX icon

pypi coverage support-version license build commit

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 RewriteResult with 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 .githooks and chmod +x .githooks/pre-commit to be prompted to run make develop, make test, and pytest before 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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pygitx-0.2.2-cp39-abi3-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

pygitx-0.2.2-cp39-abi3-manylinux_2_34_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

pygitx-0.2.2-cp39-abi3-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file pygitx-0.2.2-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pygitx-0.2.2-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

Hashes for pygitx-0.2.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fc6776d0fdb14d47a8e089be79c5d69a5ab73df54876c214d6b0187c5b4412ec
MD5 3b690a645adf191a0bac850071587ac4
BLAKE2b-256 9aec169c9aaed5ba700914008da757a79fa1d2911485eb503f3fc0b35855f9a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygitx-0.2.2-cp39-abi3-win_amd64.whl:

Publisher: publish-to-pypi.yml on zangjiucheng/pygitx

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

File details

Details for the file pygitx-0.2.2-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pygitx-0.2.2-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a58a312467a5c2ed9f94843a87e70dd3c244e7f66df042c87f77b2b37610dd3b
MD5 2783e787e51670f6b85e37df44288e97
BLAKE2b-256 93dd7e631b021362752473fcdbea268a8a764866f85722bf307829cd5fcb45b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygitx-0.2.2-cp39-abi3-manylinux_2_34_x86_64.whl:

Publisher: publish-to-pypi.yml on zangjiucheng/pygitx

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

File details

Details for the file pygitx-0.2.2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pygitx-0.2.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23b572b182bb20d310d504ebd5b058096c3467c87c1afde9d9a2c95d55cd90a9
MD5 1719a79e27aba740efcaa7e7cfb5282b
BLAKE2b-256 32a3d50ad45a01f0394499bee0c5d4077f3f8d4fa608cb87ebeac0b90b96860e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygitx-0.2.2-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: publish-to-pypi.yml on zangjiucheng/pygitx

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