Lefthook is a fast, powerful, and simple Git hooks manager. Written in Go, it streamlines development workflows by automating tasks like linting and testing during Git operations. It is actively maintained with frequent releases, currently at version 2.1.6, often seeing updates on a monthly or bi-monthly cadence.
pip install lefthookNo compatibility data collected yet for this library.
After installing, create a `lefthook.yml` file in your project root to define hooks. Then, run `lefthook install` to set up the Git hooks. The provided `lefthook.yml` snippet demonstrates a `pre-commit` hook that runs `flake8` for linting and `black` for formatting on staged Python files, automatically staging `black`'s fixes. Lefthook runs commands in parallel by default, improving efficiency.
Review your `lefthook.yml` configuration and CLI usage against the v2 documentation. Update `exclude` patterns to use globs, replace `skip_output` with `output`, and adjust CLI commands as needed.
Ensure the `lefthook` executable's directory is correctly added to your system's PATH. For hanging or new window issues, try disabling `parallel: true` for problematic hooks on Windows, or explore specific `runner` configurations if applicable. Recent versions have improved Windows path normalization.
Ensure `lefthook` is installed globally (e.g., via `pipx install lefthook`) rather than relying on `npx`. If remote configs are used, ensure they are cached or accessible offline, or use `LEFTHOOK=0 git commit` to bypass hooks when offline.
Configure the tools used in your `lefthook` commands (e.g., linters, formatters) to output without colors. For instance, many tools support a `--no-color` or `--color=never` flag.
Manually add the directory containing the `lefthook` executable to your system's PATH. If installed via npm, this might be `%APPDATA%\npm` or similar; for pipx, it's typically `~/.local/bin` on Linux/macOS or `%USERPROFILE%\AppData\Roaming\Python\Scripts` on Windows.
Disable `parallel: true` for the affected hooks in `lefthook.yml` when on Windows. Ensure `lefthook` is updated to the latest version for relevant fixes. Investigate specific commands that trigger the issue and adjust their execution or use `no_tty: true` in `lefthook.yml` as a potential workaround if applicable.
Ensure `lefthook` is installed locally via pip/pipx rather than relying on `npx` in hooks. If you have remote configs, manage them carefully. As a temporary workaround, prepend `LEFTHOOK=0` to your `git commit` command (e.g., `LEFTHOOK=0 git commit -m "fix"`) to bypass hooks.
Modify the commands in your `lefthook.yml` to explicitly disable colored output. For example, use `eslint --no-color`, `prettier --color always`, or similar options for your linters/formatters.
Ensure your local branch is tracking an upstream branch (e.g., `git push -u origin your-branch`). Double-check the `glob` patterns in your `lefthook.yml` to ensure they correctly identify files for the intended commands.
No dependency data recorded yet.