[0]: https://github.com/jdx/mise
I think hk does do all those things, but it's a bit obscured by the focus on Git hooks in the docs. But the docs are also still in a super early state, so maybe that will be fleshed out more in the future.
1. Link the scripts from the worktree to the .git/hooks directory - perhaps using a bootstrap script.
Ref: https://codeinthehole.com/tips/tips-for-using-a-git-pre-comm...
2. Declare the directory in the worktree to be the local git hooks directory.
1. https://git-scm.com/docs/githooks
2. https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
Here is another site dedicated to git-hooks. You'll find some good examples and resources there:
They did: Lefthook lets you define a "group" where you can specify that every command should be done in parallel: https://lefthook.dev/configuration/group.html. In addition, it's possible to configure the whole hook to run in parallel through another property: https://lefthook.dev/configuration/parallel.html.
I'm assuming that Hk's innovation here is that it's a bit smarter with what it runs in parallel. Maybe it uses the globs to automatically run commands in parallel which targets different files?
> "Rust is faster" as an off the cuff comment that should have been left out seeing it has triggered some folks to hyper focus on that point.
It's not a a hyper focus: This was the first reason (out of only three) that Hk itself presented as a reason to use it over Lefthook. So yes, I agree: It should have been left out if the intention wasn't for people to focus on it. Put it somewhere in a footnote if it's not so relevant.
In less than 40 lines of nix, most of which is boilerplate, you have fully cross-platform automatically installed and declaratively managed hooks, as part of your repo.
Need to run it in CI too? Well, no problem! Nix runs equally well in CI as it does locally.
Check this flake for example:
https://github.com/Azeirah/remarks/blob/main/flake.nix
See line 62 in the shell script.
This flake:
1. Manages ALL my dev env dependencies. Including even the specific version of bash that the script is running on, also the specific python dependencies down to the bit.
2. It's (posix-compliant) cross-platform, so it runs on MacOS, WSL, Linux, NixOS, ARM, x86 etc. Also docker.
3. It uses no specialized tools other than Nix, which is now a 20 year old Linux project which is quickly gaining even more traction. Nix is a programming language for reproducible, reliable and declarative dependency management (think docker but with a pure and functional programming language, rather than a recipe with installation instructions)
4. It also creates binaries as well as docker images from the binary. The docker image is like 2 lines of extra code.
Highly highly recommended. It's a bit difficult to wrap your head around initially, but holy damn if all dependency management problems don't just magically disappear forever once you learn Nix.
And I mean ALL of them. Whether it's Linux packages, docker containers, development environments, CI, virtual machines, containers, compilers, C headers from a 1970 Bell Labs project. No matter the architecture or OS (except Windows! :D).
Oh, did I mention it has a lockfile? So you can rollback or upgrade piecewise? Whenever you want?
It's like a programmable version of the superset of npm, cargo, pip, apt, brew, composer, gem, make, cmake, docker, git, Jenkins and even Linux itself (if you dare go the way of NixOS)
- Pre-commit hook setup
- Run locally anytime (`pre-commit run -a`)
- Check in CI (as Nix flake check)
Example repo: https://github.com/srid/haskell-template
The pre-commit configuration: https://github.com/srid/haskell-template/blob/master/nix/mod...
I'll put these benchmarks on that page in different scenarios.
Update: https://github.com/jdx/hk/blob/main/docs/public/benchmark.pn...
As I said in the doc I think real-world performance in a large codebase will show that hk is even faster still—though that will depend on the project in question. It's really just a matter of providing the right levers in the right places and having good defaults.
Despite what everyone here says: yeah, just doing CLIs in Rust will be faster than Go and for CLIs like this milliseconds matter.
> Despite what everyone here says: yeah, just doing CLIs in Rust will be faster than Go and for CLIs like this milliseconds matter.
You've shown nothing to suggest that this is true. On my computer "lefthook --help" is exactly as fast as "hk --help". There's also many other differences between these tools. YAML vs Pkl is one difference. Another one is that Lefthook shells out to "git" to determine the list of staged files, while Hk uses libgit2. Which of these are faster? I'm not sure! It might even depend on repository size and/or other details. And as we all agree: In practice the parallelism strategy will matter the most.
> As I said in the doc I think real-world performance in a large codebase will show that hk is even faster still
I'm absolutely sure that you will be able to tweak hk to become the "fastest" pre-commit runner in your designated category. I'm also pretty sure that similar optimizations will apply quite easily to Lefthook. They're after all doing pretty much the same thing.
> then you removed the parallel support
that was not intentional. I fixed that, but it didn't change the results that much:
https://github.com/jdx/hk/commit/dfe1fc1724b8f6c43b184dc98ac...
In any case, I don't know why anyone would take such a new project "seriously". I certainly don't.
mise supports an experimental bootstrapping feature: it can download itself and install the tools required for the project.
See https://mise.jdx.dev/cli/generate/bootstrap.html and https://mise.jdx.dev/continuous-integration.html#bootstrappi...