Better `pre-commit`, re-engineered in Rust
Project description
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, some features are still not 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,scriptandfail.
Features
- 🚀 A single binary with no dependencies, does not require Python or any other runtime.
- ⚡ About 10x faster than
pre-commitand uses only a third of disk space. - 🔄 Fully compatible with the original pre-commit configurations and hooks.
- 🐍 Integration with
uvfor 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-commitwithprefligitin your commands - Your existing
.pre-commit-config.yamlworks 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 way faster
- It is about 10x faster than
pre-commitand uses only a third of disk space. - 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
uvfor 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 sub-project can have its own
.pre-commit-config.yamlfile. prefligit runhas some improvements overpre-commit run, such as:prefligit run --directory <dir>runs hooks for files in the specified directory, no need to usegit ls-files -- <dir> | xargs pre-commit run --filesanymore.prefligit run --last-commitruns hooks for files changed in the last commit.
- (TODO): prefligit provides shell completions for
prefligit run <hook_id>command, so you can easily find the available hooks.
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.22/prefligit-installer.sh | sh
# On Windows
powershell -ExecutionPolicy ByPass -c "irm https://github.com/j178/prefligit/releases/download/v0.0.22/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
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 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 prefligit-0.0.22.tar.gz.
File metadata
- Download URL: prefligit-0.0.22.tar.gz
- Upload date:
- Size: 146.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74a54ec6371a33bb6d5b2a4436836a96d84f32e2e0b4441dd47579328d475761
|
|
| MD5 |
5e402abeba4837a1cb9e8accf2a2f39d
|
|
| BLAKE2b-256 |
f689f1c66a5e2da3fd181f4196f1d3245d4854a6f391ffba9ff4de27383ec7f1
|
File details
Details for the file prefligit-0.0.22-py3-none-win_amd64.whl.
File metadata
- Download URL: prefligit-0.0.22-py3-none-win_amd64.whl
- Upload date:
- Size: 4.3 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b942e63a907ac51f0ba28167d35cc3eca26baba95f932c4ea75dc6eb004e7cf
|
|
| MD5 |
5ede03e7269ff0fc2ed30b4f5f165bde
|
|
| BLAKE2b-256 |
e737093a7a1d5731edb76c9bc1e7a9767358e6be2b12b7077081ff5f36d5bf7e
|
File details
Details for the file prefligit-0.0.22-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: prefligit-0.0.22-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.2 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc70f3c30d9112858bd1af61ec9f02c6b4bac8740480b962d1880f2174795de4
|
|
| MD5 |
a641a18d0167b4722a8286a3e79c48d5
|
|
| BLAKE2b-256 |
2a8d4866693b66ec3bbb7e1ef07209a419c690994ca0c48fc42814ce14e16b72
|
File details
Details for the file prefligit-0.0.22-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: prefligit-0.0.22-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.7 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f0d21f5e42cbd2fa7603b0f6436ccab893c48ee8269b85724c0ace716807cc7
|
|
| MD5 |
6e558b89974d682a3d74a7b43b3ec62b
|
|
| BLAKE2b-256 |
48e52edcafb47a5d33bba6505a8f8e590ba022052b5d95740ceda1d0a1df8abd
|
File details
Details for the file prefligit-0.0.22-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: prefligit-0.0.22-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 4.9 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cc91ebf9b00792aed2910e7a64df02756dc83d299eaf913be5a89ad41de5f0b
|
|
| MD5 |
3467e489677f57482e7a22336368affa
|
|
| BLAKE2b-256 |
fb19c28061c8519ebb5a9b2f494163c7c1cec180a8a916be6c9bf7648fdc4954
|