42 points · by rycus86 · 8y ago · 36 comments
This is begging for nefarious things to be installed automatically.
Obviously this is an open source side project, so it won't cater to everyone, I'm just skeptical of it being the benefit that it's claimed to be.
He gives his reasonings for it here: https://github.com/git-hooks/git-hooks/wiki/Why-golang
The tl;dr is that it will eventually have features that would be nontrivial to implement with bash, and Go is easier on the development-side than C (coming from a frontend dev experience).
Luckily for you, the project already has binaries built for Mac (Darwin): https://github.com/git-hooks/git-hooks/releases
Is it not a violation of abstraction to turn your version control system into a build/test/CI system?
Local staging, committing, rebasing, cherry-picking, etc. operate on arbitrary line-delimited text. I should be able to do those without triggering non-VCS things.
Do you want to add a convenient auto format step with your IDE, githooks, or inotifywait? Okay. But changing how a standard, fundamental tool works for everyone...
What's wrong with `make format`?
Most checks should be in the CI but git hooks allow a team to add rules without affecting all teams at once. When rules turn out good they can be enforced on everybody via CI. Even a single team might have dozens of machines, so they don't want to roll out git hooks manually.
This is the niche use case I can think of. Still, it exploits git to do things it is not made for. This is asking for trouble elsewhere.
The next he time he'll think twice if he should wait for the failed CI build or just install the hooks locally.
Internally / privately it's generally a lesser risk, but if this is open source please consider removing that feature for better security. That or document it incredibly clearly.
Build scripts are explicitly called by a user, a git hook is a side effect they've elected to setup. In this case the tool is adding side effects to commands without the user explicitly choosing to have them.
I can see someone downloading a repository, running a few git commands to make a couple of changes and not realising the git hooks have been installed and the behaviour of a command has changed. Once you're near that scenario, you're just opening up security holes rather than fixing them. It'd be better to have a script one can run after a git clone explicitly that is documented in the project repository.
"To setup git hooks to speed up development, run ./init-hooks." is easy, clear, makes it difficult to do it without knowing what's happening.