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, 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, 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 way faster

  • It is about 10x faster than pre-commit and 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 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 sub-project can have its own .pre-commit-config.yaml file.
  • prefligit run has some improvements over pre-commit run, such as:
    • 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.21/prefligit-installer.sh | sh

# On Windows
powershell -ExecutionPolicy ByPass -c "irm https://github.com/j178/prefligit/releases/download/v0.0.21/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.21.tar.gz (144.3 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.21-py3-none-win_amd64.whl (4.3 MB view details)

Uploaded Python 3Windows x86-64

prefligit-0.0.21-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.21-py3-none-macosx_11_0_arm64.whl (4.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

prefligit-0.0.21-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.21.tar.gz.

File metadata

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

File hashes

Hashes for prefligit-0.0.21.tar.gz
Algorithm Hash digest
SHA256 a91eb823d19c51d481344c4fef96d458f418f406116800ca7ff621d589be171e
MD5 b20d7a3733e2ef7082bcaa0516a1f695
BLAKE2b-256 9aff1601fd54ec4ecfb482324590f796f1a146104eb03e4bcbe903287ea540bf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prefligit-0.0.21-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1c24da4982bd1b3bfdbd48f877d63adcb969dcac63f5035f6d2cc0b1f130d2be
MD5 32deaec2d29a1efdb2bb04686968a184
BLAKE2b-256 b36304b8078e231c12f70c0c8898819abddbae51dddced3582637bc53d7a2a21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prefligit-0.0.21-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2aa5402399ce2ca81963852b16009495f9707446e86799a75993914bc3c17874
MD5 daa72af2d2c0d8f08c8cacbc91886b9c
BLAKE2b-256 0160a210f5086f3af69bc75f890e508c041469769233b16703ab3758e0fee85a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prefligit-0.0.21-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d02d7faa19e2aa48cf3f0fc582f18639e571755430796381c4e5a046341b175
MD5 436f233c69270c466c79e2d4e291be7d
BLAKE2b-256 3778109fa74031a015431e2e1cdcd23e40fbfd0563c088c564950429d8b2f197

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prefligit-0.0.21-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9afe8ca5fe6d5926acae4867bb863040d0024f421c3f08475a8e7beee96c6f2b
MD5 3276dd4a9a28b73a3a203c3402c120c2
BLAKE2b-256 787a1f6c029ae9cf4e69ea1ba56d4f2820c7d74a7212eb18af60997eebbf0d83

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