pre-commit and other git hooks

I do not disagree with Theo on the pre-commit topic. I just watched today's pre-commit video https://www.youtube.com/watch?v=LL01pLjcR5s and coincidentally just yesterday I had rewatched one of his older videos on pre-commit https://www.youtube.com/watch?v=RAelLqnnOp0 I am all about CI/CD and use tools like GH actions a lot, but also admit I have work do do in some projects to build out better CI. So why am I opening this thread? In my head when I hear pre-commit hooks, I often mentally substitute that with "any kind of git hook" and want to talk about that. I wonder if anyone else conflates "any kind of git hook" in their head the way I do (or if I'm just off-base). One of the ways I use git hooks that's actually relevant to Theo's video from today is to run npm install via https://github.com/thdk/package-changed?tab=readme-ov-file#use-git-hooks-to-run-package-changed-automatically with post-checkout, post-merge, and post-rebase. To be specific about how this works (for those who haven't uses package-changed) it checks if your package.json (and optionally package-lock.json) has changed by storing a hash and checking against that hash to determine if npm install needs to run. This is relevant to what Theo mentions around the 7:50 mark in today's video. With this in place (assuming a clever dev hasn't /dev/null'd husky) the problem of pulling new commits that include changes to dependencies for the most part goes away. It's not a substitute for CI by any means and shouldn't stop anyone from working. It's just meant to be a gentle assist. So I'm curious what everyone here thinks of the above use case, and also would love to hear if there are any other good uses of git hooks that anyone likes, or even valid uses of pre-commit (aside from the secret scanning idea mentioned in the video).
Theo - t3․gg
YouTube
The dangers of precommit hooks
I can't believe I'm talking about precommit hooks again but HERE WE ARE. MY OTHER COMMIT HOOKS VID https://www.youtube.com/watch?v=RAelLqnnOp0 Check out my Twitch, Twitter, Discord more at https://t3.gg S/O Ph4se0n3 for the awesome edit 🙏
Theo - t3․gg
YouTube
Precommit Hooks Are Bad
Precommit hooks are the actual worst thing and I hope this convinces y'all to use them less. ALL MY CONTENT IS FILMED LIVE ON TWITCH AT https://twitch.tv/theo ALL MY BEST MEMES ARE ON TWITTER FIRST https://twitter.com/t3dotgg ALL THE COOLEST PEOPLE ARE IN MY DISCORD https://t3.gg/discord ALL MY VIDEOS ARE POSTED EARLY ON PATREON https://www.pat...
GitHub
GitHub - thdk/package-changed: Tells you whether or not dependencie...
Tells you whether or not dependencies in package.json have been changed. - thdk/package-changed
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server