Skip to main content

Git diff parser.

Project description

fugit

PyPI pdm-managed pre-commit.ci status Supported Python versions

Git diff handling in Python.

Motivation

sed fugit interea fugit irreparabile tempus (“meanwhile, the irreplaceable time escapes”

Despite the existence of GitPython, it remains awkward to access structured diffs for a given repo. This is particularly desirable for large diff sets, such as those created when migrating between linters (such as Black to Ruff, as motivated this library). In such cases it's desirable to be able to see clearly what the actual substance of the set of diffs is, but without programmatic means to access this set simply it becomes a manual effort (with each reader re-duplicating others' efforts or else just skipping the task and not making an informed decision).

Before writing this library I investigated fast parsing approaches (Pydantic with Rust's regex crate in particular) and reviewed the internals of GitPython, as well as its API for accessing diffs.

The goal of this library is to make this specific facet of git easy to work with.

Installation

pip install fugit

Usage

Expected interface:

from fugit import diff

diff = diff(repo_path="/path/to/your/repo")

Development

  • To set up pre-commit hooks (to keep the CI bot happy) run pre-commit install-hooks so all git commits trigger the pre-commit checks. I use Conventional Commits. This runs black, flake8, autopep8, pyupgrade, etc.

  • To set up a dev env, I first create a new conda environment and use it in PDM with which python > .pdm-python. To use virtualenv environment instead of conda, skip that. Run pdm install and a .venv will be created if no Python binary path is found in .pdm-python.

  • To run tests, run pdm run python -m pytest and the PDM environment will be used to run the test suite.

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

fugit-0.0.2.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

fugit-0.0.2-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page