Live data from Hacker News

Prek: A better, faster, drop-in pre-commit replacement, engineered in Rust

github.com

131–133 of 133 posts

Re: Prek: A better, faster, drop-in pre-commit replacement, engineered in Rust

#131
post #27

Earlier quoted context omitted.

the second the hooks modify the code they've broken your sandbox I think wasi is a cool way to handle this problem. I don't think security is a reason though.

I wouldn't want hooks modifying the code. They should be only approve/reject. Ideally landlock rules would give them only ro access to repo dir

It's going to be optional - the hooks will always fix the code if they can, but then you can supply a `--no-fix` flag (or config) if you want to tell it to not actually apply those changes to the real filesystem.

It doesn't need Landlock because WASI already provides a VFS.

Re: Prek: A better, faster, drop-in pre-commit replacement, engineered in Rust

#132

Earlier quoted context omitted.

I leave unstaged files all the time, not sure what you mean.

Without extra shenanigans if you have an unstaged file that fails your test suite then pre-commit will reject your commit even if the staged files are error free.

Our stuff is configured to only run on staged files.

Re: Prek: A better, faster, drop-in pre-commit replacement, engineered in Rust

#133
post #118

Earlier quoted context omitted.

It depends. I wrote a pre-commit hook (in shell, not precommit the tool) at a previous job that ran terraform fmt on any staged files (and add the changes to the commit) because I was really tired of having people push commits that would then fail for trivial things. It was overrideable with an env var. IMO if there’s a formatting issue, and the tool knows how it should look, it should fix it for you.

The standard way for this with current tools is to have the formatter/linter make the changes but exit with a non-zero status, failing the hook. Then the person reviews the changes, stages, and commits. (That's what our setup currently has `tofu fmt` do.) But if you don't want to have hooks modify code, in a case like this you can also just use `tofu validate`. Our setup does `tflint` and `tofu validate` for this pur…

> make the changes but exit with a non-zero status

That's reasonable. My personal (and that of my team at the time) take was that I was willing to let formatting - and only formatting - be auto-merged into the commit, since that isn't going to impact logic. For anything else, though, I would definitely want to let submitter review the changes.

Post reply on HN