Git Hooks are awesome - in theory.
They let us:
- test before doing a commit. ✅
- lint code before a push. ✅
- prevent interns from crashing production due to untested code 😱
But let's be honest, how many of us really use them huh?
Problem with Hooks
Most of us probably don't use them mainly because:
- They live inside of
.git/hooks
directory - They can't be version controlled
- Feel like a trap - what if I mess up and do push to production but the hook didn't work and now the entire site crash(maybe that's why the internet is down today?)
So, most of us, like me just:
- Ignore them completely
- Or if you feel like killing yourself, you code in JS and can just use Husky - Which is amazing but nodejs only
The solution - GetHooky
Feeling trapped to use node everywhere(even the backend 😱), I decided to write a CLI based tool, GetHooky, to manage all your git hooks for you. And you can also version control it and share it with your team!
Think of it as Husky, but for everyone 💪.
For the purpose of flexing GetHooky is written in rust... competitor go.
🔧 How Hooky works
Very simple!
You just initialize a repository with hooky
hooky init
This create's a directory by the name of .hooky
, where all your hooks will live, you can version control this.
Then add a hook
hooky add pre-commit "echo 'HELP ME!'"
This creates a .hooky/pre-commit
file which contains the command you want, in this case echo 'HELP ME!'
will be stored.
And then finally install it
hooky install
This updates the hooks present in the .git/hooks
directory, to prevent GetHooky from accidently touching hooks which you don't want to change, your personal hooks, hooky adds a marker on top of each file which it controls # hooky ya rookie
this tells it to touch only this file.
Work anywhere, anytime
No nodejs, no dependencies, not even Go!
GetHooky works for:
- Too little abstraction pythonist
- Blue hair rust coders
- JS andys
- Guy working at go...ogle
- And everyone
📦 Installation
You can install GetHooky with curl or wget like so:
method | curl some URL |
---|---|
curl | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ezpieco/gethooky/master/tools/install.sh)" |
wget | sh -c "$(wget -O- https://raw.githubusercontent.com/ezpieco/gethooky/master/tools/install.sh)" |
For windows I would highly recommend you to change your OS... just download it from the release page
GetHooky is exactly what you need to handle your interns and yourself, cause hey? We all have crashed production at least once in our life! Trust me Bro, I have first hand experience(nothing to do with the recent activities)
Check out in -> Github
Docs -> Click right here soy devs
NOTE: As of now GetHooky is in early release, I would love feedbacks, feature requires, ideas and anything crazy you got!
Also don't forget to give it a ⭐️ on GitHub!
👉 Do you use Git hooks in your projects? Why or why not?
Let me know in the comments!
Hello content creators! If you’ve ever published on Dev.to, you may be eligible for a limited-time token giveaway. Connect your wallet here. no gas fees. – Dev.to Airdrop Desk