Top
Best
New

Posted by fortuitous-frog 7 hours ago

Prek: A better, faster, drop-in pre-commit replacement, engineered in Rust(github.com)
156 points | 75 commentspage 2
semiinfinitely 6 hours ago|
I always just disable pre-commit
aaronblohowiak 6 hours ago||
So if you are using multiple languages to have scripts that run off your pre-commit hook, this is like a package and language runtime management system for your pre-commit hook build system? Rather, I think this is a reimplementation of such a system in rust so it can be self contained and fast.

This is the kind of thing I see and I think to myself: is this solving a problem or is this solving a problem that the real problem created?

Why is your pre-commit so complicated that it needs all this? I wish I could say it could all be much simpler, but I’ve worked in big tech and the dynamics of large engineering workforces over time can make this sort of thing do more good than harm, but again I wonder if the real problem is very large engineering teams…

egorfine 5 hours ago||
What difference does it make that it's written in Rust? Why is that so much a selling that it made it into the title?
fishgoesblub 4 hours ago||
To entice people who are fluent in said language, or those who are looking for something compiled and performant. If I see a project written in (java|type)script, I know to avoid it.
evetools 2 hours ago||
Anyone using on very big projects can vouch for the speed of things?
xyzzy_plugh 6 hours ago||
Another commenter is currently down voted for something similar, but I'll share my controversial take anyways: I hate pre-commit hooks.

I loathe UX flows where you get turned around. If I try to make a commit, it's because that I what I intend to do. I don't want to receive surprise errors. It's just more magic, more implicit behavior. Give me explicit tooling.

If you want to use pre-commit hooks, great! You do you. But don't force them on me, as so many projects do these days.

chippiewill 9 minutes ago||
But no one forces pre-commit hooks onto you? You can just not install the hook into git and run the tool manually instead.
nitnelave 5 hours ago|||
Client-side pre-commit hooks are there to help you in the same way that type checking (or a powerful compiler) is there to help you avoid bugs. In particular with git, you can skip the hooks when committing.

Now, if the server enforces checks on push, that's a project policy that should be respected.

sa46 4 hours ago||
The problem is that pre-commit hooks are much slower with a much higher false-positive rate than type checking.

Pre-commit checks should be opt-in with CI as the gate. It's useful to be able to commit code in a failing state.

chippiewill 10 minutes ago||
No one forces you to install the pre-commit hook on your local checkout so what you're suggesting is universally the case. You're perfectly free to just run it manually or let it fail in CI or use `--no-verify` when committing to skip the hook if you install it.
chuckadams 4 hours ago||
I use exactly one such hook, and that's to add commit signoff because of a checklist-compliance item called DCO that fails all PRs unless they have the sign-off trailer added by `git commit -s`. I've long argued that we should be enforcing actual signed commits instead, but compliance has never been about doing the sensible thing.

It's as simple as a script with a cp command that I run after any clone of a repo that requires it; certainly doesn't require anything as elaborate as a hook manager.

iFire 6 hours ago||
I don't understand. The whole point of pre-commit is it's a gateway to the operating system and also creating a ecosystem of pre integration continuous integration scripts. Scripts that are not rust.
rurban 7 hours ago||
Not just faster than pre-commit, and totally compatible. Also with more features.
verdverm 6 hours ago|
Voting and comment rings are against HN guidelines
teaearlgraycold 3 hours ago||
It doesn’t seem like this solves the main issues with pre-commit hooks. They are broken by design. Just to name 2, they run during rebase and aren’t compatible with commits that leave unstaged files in your tree.
tomjakubowski 1 hour ago||
> they … aren’t compatible with commits that leave unstaged files in your tree.

It's a little surprising that git doesn't pass pre-commit hooks any information, like a list of which files were changed in the soon-to-be-made commit. git does so for pre-push, where it writes to a hook's stdin some information about the refs and remotes involved in the push.

I wonder if many pre-commit hooks, like the kind which run formatters, would be better off as `clean` filters, which run on files when they are staged. The filter mechanism makes it easier to apply just to the files which were changed. In the git docs, they even use a formatter (`indent`) as an example.

https://git-scm.com/book/ms/v2/Customizing-Git-Git-Attribute...

bradleyy 1 hour ago||
I leave unstaged files all the time, not sure what you mean.
BewareTheYiga 7 hours ago|
This has been such a breath of fresh air. It was seamless to drop into my projects.