DEV Community

Discussion on: A simple pre-commit hook that saves you big time!

Collapse
 
swarupkm profile image
Swarup Kumar Mahapatra

Smaller commits, and unit testing the code will not let syntax errors at the first place. And hence you won't need that pre-commit.

Collapse
 
rahul_ramfort profile image
Rahul

Agreed. That's the right way to do.

But I don't see any harm in having this either. Particularly for the "last-minute changes". Human errors are always possible, so why not put some checks.

To err is human; to automate, divine

Collapse
 
nombrekeff profile image
Keff

We use pre-commit hook at work to run tests before committing and we also run tests in GitHub actions on any PR to prevent human error. It's been working great for now.

The hook could also be used to lint commit messages if the company or project uses some automated changelog generator or some committing standard.

Thread Thread
 
rahul_ramfort profile image
Rahul

Thanks for adding this mate. I will make this hook, lint commit messages as well.