Skip to main content

Better `pre-commit`, re-engineered in Rust

Project description

prefligit

Development Status CI GitHub downloads

prefligit

pre-commit is a framework to run hooks written in many languages, and it manages the language toolchain and dependencies for running the hooks.

prefligit is a reimagined version of pre-commit, built in Rust. It is designed to be a faster, dependency-free and drop-in alternative for it, while also providing some additional long-requested features.

[!WARNING] This project is still in early stage of development, only a few of the original pre-commit features are implemented. It is not production-ready yet, but feel free to try it out and provide feedback.

Current supported languages are python, node, go, docker, docker-image, system, script and fail.

Features

  • 🚀 A single binary with no dependencies, does not require Python or any other runtime.
  • ⚡ About 10x faster than pre-commit and uses only a third of disk space.
  • 🔄 Fully compatible with the original pre-commit configurations and hooks.
  • 🐍 Integration with uv for managing Python virtual environments and dependencies.
  • 🛠️ Improved toolchain installations for Python, Node.js, Go, Rust and Ruby, shared between hooks.
  • 📦 Built-in implementation of some common hooks.
  • 🏗️ (TODO) Built-in support for monorepos.

How to migrate

prefligit is designed as a drop-in replacement:

  • Install prefligit.
  • Replace pre-commit with prefligit in your commands
  • Your existing .pre-commit-config.yaml works unchanged
$ prefligit run
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
typos....................................................................Passed
cargo fmt................................................................Passed
cargo clippy.............................................................Passed

For configuring .pre-commit-config.yaml and writing hooks, you can refer to the pre-commit documentation as prefligit is fully compatible with it.

Why prefligit?

prefligit is 10x faster and more efficient

  • It is written in Rust, which is more efficient than Python.
  • It redesigned how hook environments and toolchains are managed, they are all shared between hooks, which reduces the disk space usage and speeds up the installation process.
  • Repositories are cloned in parallel, and hooks are installed in parallel if their dependencies are disjoint.
  • It uses uv for creating Python virtualenvs and installing dependencies, which is known for its speed and efficiency.
  • It implements some common hooks in Rust, built in prefligit, which are faster than their Python counterparts.

prefligit provides a better user experience

  • No need to install Python or any other runtime, just download a single binary.
  • No hassle with your Python version or virtual environments, prefligit automatically installs the required Python version and creates a virtual environment for you.
  • (TODO): Built-in support for workspaces (or monorepos), each project can have its own .pre-commit-config.yaml file.
  • prefligit run has some improvements over pre-commit run, such as:
    • (TODO): prefligit run --directory <dir> runs hooks for files in the specified directory, no need to use git ls-files -- <dir> | xargs pre-commit run --files anymore.
    • prefligit run --last-commit runs hooks for files changed in the last commit.
  • prefligit provides shell completions for bash, zsh, fish and powershell.

Installation

Standalone installer

prefligit provides a standalone installer script to download and install the tool:

# On Linux and macOS
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prefligit/releases/download/v0.0.20/prefligit-installer.sh | sh

# On Windows
powershell -ExecutionPolicy ByPass -c "irm https://github.com/j178/prefligit/releases/download/v0.0.20/prefligit-installer.ps1 | iex"
PyPI

prefligit is published as Python binary wheel to PyPI, you can install it using pip, uv (recommended), or pipx:

pip install prefligit

# or

uv tool install prefligit

# or

pipx install prefligit
Homebrew
brew install prefligit
Cargo

Build from source using Cargo:

cargo install --locked --git https://github.com/j178/prefligit
GitHub Releases

prefligit release artifacts can be downloaded directly from the GitHub releases.

If installed via the standalone installer, prefligit can update itself to the latest version:

$ prefligit self update

Acknowledgements

This project is heavily inspired by the original pre-commit tool, and it wouldn't be possible without the hard work of the maintainers and contributors of that project.

And a special thanks to the Astral team for their remarkable projects, particularly uv, from which I've learned a lot on how to write efficient and idiomatic Rust code.

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

prefligit-0.0.20.tar.gz (142.4 kB view details)

Uploaded Source

Built Distributions

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

prefligit-0.0.20-py3-none-win_amd64.whl (4.2 MB view details)

Uploaded Python 3Windows x86-64

prefligit-0.0.20-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

prefligit-0.0.20-py3-none-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

prefligit-0.0.20-py3-none-macosx_10_12_x86_64.whl (4.9 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file prefligit-0.0.20.tar.gz.

File metadata

  • Download URL: prefligit-0.0.20.tar.gz
  • Upload date:
  • Size: 142.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.4

File hashes

Hashes for prefligit-0.0.20.tar.gz
Algorithm Hash digest
SHA256 01788daad6d7521aef7474a811d11f5f32c099ace458e9b798a8baeb419a5848
MD5 43ab9b92daf3503133a3e1c1536c38be
BLAKE2b-256 cd8f95f7a3e80f910677be1224f59bdfd24d8b1234d4a3650c7e66adcccadfe4

See more details on using hashes here.

File details

Details for the file prefligit-0.0.20-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for prefligit-0.0.20-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 fc89e6355aac4c93807573891b5385346796e61a28d9a49c905059218280edb9
MD5 061c84c8ee4f5ecf194dab7ea4d5a931
BLAKE2b-256 0692bd02a34a173a0a2a8d0b8bbe0e25540e43f4f20480ba1f58526a11692758

See more details on using hashes here.

File details

Details for the file prefligit-0.0.20-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for prefligit-0.0.20-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 83356b1293be483c50b61d5a4501dff31800de4fa88797427cd5aa5e01b20bb4
MD5 1d3d6f85fda9fd30d9f8ac32724a1caa
BLAKE2b-256 d363a712986d2e8bb4da192c102ed938d016ad3344e3ed0a78f3d86cdb887cf0

See more details on using hashes here.

File details

Details for the file prefligit-0.0.20-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for prefligit-0.0.20-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38b34319f007c227d09e27be6fbb43e929db80430f16c67210030c00e9187a8c
MD5 86d0efeeadc4ae1be0c225686b2a0808
BLAKE2b-256 eaf211a3bd206b737a96c864f2f5d62982cfcab4d906d6421124e363b22e16db

See more details on using hashes here.

File details

Details for the file prefligit-0.0.20-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for prefligit-0.0.20-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ccc337492344196358fbedfdc41db5f741c46aecdb87852801ff053335ee37d1
MD5 b435edb61dd50ff060e099981fe92551
BLAKE2b-256 dfe32ee35d2d74cc7bb707588657225153ac0f2ca0451b4d392afa6fe7cef1aa

See more details on using hashes here.

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