hk 2.8.2 makes hk check <file> resolve paths from the directory you run it in, and stops hk processes that start at the same time from reading half-written config cache files. cargo install hk builds now include the Pkl package, so offline mode works with them, and hk install --global reports the git config file it actually wrote to.
Fixed
-
File arguments are resolved from the directory hk was run in (#1754, @jdx). hk changes to the repository root before it runs, so relative file arguments used to be resolved from the root. Running
hk check a.jsinsidesub/checked<root>/a.jsinstead ofsub/a.js. Paths given as arguments or through--files0-fromare now resolved from where you ran hk. Absolute paths and paths outside the repository still work. Fixes #1753.$ cd sub $ hk check a.js # checks sub/a.js (previously <root>/a.js) $ hk check ../a.js # checks a.js at the repository root $ hk check . # checks sub/
-
No more cache parse warnings when hk processes start at the same time (#1750, @zachbornheimer). Several hk processes can start together, for example a pre-commit and a pre-push hook, or agents running in parallel. When that happened, one process could read a config cache entry another was still writing. It then printed
failed to parse cache file ...: EOF while parsing a valueand evaluated the config again. hk now writes each cache entry to a temporary file and renames it into place, so readers always get a complete entry. A replaced entry keeps its Unix file mode. If a write fails, the error names the entry. -
cargo install hkbuilds can run offline (#1755, @jdx). The crate on crates.io was published without the generated Pkl builtins, so builds from it embedded an empty Pkl package. WithHK_PKL_OFFLINE=1, they failed withpackage is not cached and offline mode is enabled, even whenhk.pklpinned the installed version. The publish step now generates the package and fails if it is missing. Starting with this release,cargo install hkembeds the package just like the prebuilt release binaries do. -
hk install --globalnames the git config file it wrote to (#1758, @sahidvelji). Git writes global settings to~/.config/git/configwhen~/.gitconfigdoesn't exist, or to$GIT_CONFIG_GLOBALif that is set. hk installed the hooks in the correct file but always said~/.gitconfig. hk now asks git which file holds the hooks. Messages fromhk install --global,hk uninstall --global, skipped per-repo installs andhk install --force-localnow name that file. If git can't report one, the messages say "the global git config".
New Contributors
- @zachbornheimer made their first contribution in #1750
Full Changelog: v2.8.1...v2.8.2
💚 Sponsor hk
hk is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.
If hk speeds up your pre-commit loop or makes linting less painful, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep hk fast, free, and independent.