Repository navigation
v0.4.0
π― Highlights
prek native mode: husky-rs now installs prek hooks directly into
.git/hooks/
instead of relying on.husky/orcore.hooksPath. This makes prek-managed
projects cleaner and avoids conflicts between husky-rs and prek's own hook
management. Standalone.husky/mode continues to work exactly as before.
β οΈ Breaking Changes
- MSRV bumped to 1.83 (from 1.78). For most users this requires no action
since Rust developers typically use rustup. Users on Debian Bookworm or
Ubuntu 24.04 LTS apt packages already needed rustup even for 1.78. - prek mode now clears
core.hooksPath. Previously husky-rs called
prek installwhich wrote shims to the directory pointed to by
core.hooksPath(usually.husky/). Now husky-rs clearscore.hooksPath
and passes--git-dir .gitto prek, so hooks are installed natively into
.git/hooks/. If you had a customcore.hooksPath, it will be removed. - prek mode ignores
.husky/. When a prek config (prek.toml,
.pre-commit-config.yaml, or.pre-commit-config.yml) exists, any existing
.husky/directory is no longer used. A warning is printed to alert you.
Pre-existing.husky/files are left untouched on disk but are not executed. - prek required in prek mode. If a prek config exists but
prekis not on
PATH, the build fails with:config found but prek is not installed; run 'cargo install prek'. Previously this was a soft fallback; now it is a hard
error to prevent silently broken hooks.
β¨ Added
- prek native mode:
prek install --git-dir .gitinstalls shims directly
into.git/hooks/. No.husky/directory required. Nocore.hooksPath
manipulation. Git uses its default hooks directory. .husky/ignored warning: When a prek config is detected alongside an
existing.husky/directory, husky-rs prints a clear warning:
prek config detected β .husky/ will be ignored (prek manages hooks via .git/hooks/).prek.tomlpriority: When bothprek.tomland.pre-commit-config.yaml
exist,prek.tomltakes precedence (matching prek's own behavior).default_install_hook_typessupport in.pre-commit-config.yamlto
control which hook shims prek installs (pre-commit, commit-msg, pre-push).default_stagessupport for hooks without explicitstages:.- New tests:
test_prek_toml_takes_priority_over_yaml,
test_husky_is_file_not_directory_fails_build(85 tests total, +2).
π§ Changed
- prek validate-config runs before any mutation. Config validation happens
first;core.hooksPathis only cleared after validation passes, preventing
partial state on failure. - Error messages include config path. Prek failures now report which config
file caused the error, e.g.:
prek install --git-dir .git failed with status exit code: 1 (config: .pre-commit-config.yaml): ... .husky/is a file β clear error. If.huskyexists as a regular file
instead of a directory, the build fails with:
.husky exists but is not a directory; remove it or replace it with a directory
π¦ Dependencies & CI
- MSRV: 1.78 β 1.83
- GitHub Actions:
actions/checkoutv6βv7,codecov/codecov-actionv6βv7
π Migration Guide
From husky-rs 0.3.x standalone mode (no prek config)
No action needed. Standalone .husky/ mode is unchanged.
From husky-rs 0.3.x prek mode (with prek config)
If you were using prek mode in 0.3.x:
-
Check your
core.hooksPath: After upgrading,core.hooksPathwill be
cleared. This is expected β prek now manages hooks in.git/hooks/directly. -
.husky/cleanup (optional): If you had.husky/from standalone mode,
it will be left on disk but ignored. You can safely delete it:rm -rf .husky/
-
Ensure
default_install_hook_typesis set: If you need commit-msg or
pre-push hooks, add to your prek config:default_install_hook_types: [pre-commit, commit-msg, pre-push]
-
Clean rebuild to trigger new behavior:
cargo clean cargo test # or cargo build
From standalone to prek mode (new)
cargo install prek
# Create .pre-commit-config.yaml or prek.toml
cargo clean
cargo test
# .husky/ will be ignored β prek manages .git/hooks/From prek back to standalone
prek uninstall --all
rm .pre-commit-config.yaml prek.toml 2>/dev/null
cargo clean
cargo test
# husky-rs falls back to standalone .husky/ modeπ Negative Cases Verified (non-exhaustive)
All tested scenarios fail safely β no bypass found:
| Scenario | Result |
|---|---|
NO_HUSKY_HOOKS=1 |
Skips installation entirely |
| Invalid YAML config | Build fails with parse error |
| prek not on PATH | Build fails with install guidance |
Empty prek.toml |
Build fails |
.husky/ is a file |
Build fails with clear error |
core.hooksPath tampered |
Auto-restored on next build |
| Broken hook script | Commit blocked by Git |
Missing .husky/ (standalone) |
No-op, build succeeds |
| Delete prek config mid-stream | Falls back to standalone |