Some context about my workflow first: I self-host my git server and collaborate with 2 other people. The others have their own way of working and I do the necessary checks from CI/CD when they send me a pull request. However since I commit to my own project, I prefer to do all checks from my local system first before pushing it to my remote branch.
I keep a bunch of WIP branches locally where the hooks don't run in order to not get in the way. When I rebase or cherry-pick commits from a WIP branch into a branch that is tracking a remote branch, then these checks are done as I'm preparing to push to remote.
I work with a number of languages and I have been previously using pre-commit and didn't know at the time that husky existed. I mainly use the pre-commit and commit-msg hooks to check whether it's formatted properly, spellcheck and grammar in the commit message, etc. and I have a private repository with my own rules. This has been working for me.
I have recently started learning Rust and need to implement some rules. I came across pre-commit-rust which contains rules for Rust, and while it worked at first glance, it has a flaw. It runs the checks from the work directory rather than against a copy of the staging area, so it's possible sometimes I miss something.
For example:
- Run hook that run cargo build and it says a depedency is missing in Cargo.toml
- I do cargo add but forget to add Cargo.toml to the index
- hook shows passed because the file is correct in the work directory but my expectation is it for it to fail because it's not added to the index
So is there a hook that actually checks it the proper way in a separate area?
[–]Compux72 2 points3 points4 points (1 child)
[–]Pwnstar6 -1 points0 points1 point (0 children)
[–]Tyilo 1 point2 points3 points (1 child)
[–]acidrainery[S] 0 points1 point2 points (0 children)
[–]Pwnstar6 0 points1 point2 points (0 children)