4 ms·
I disagree with the usage of githooks for linting and testing. It discourages frequenting committing which is a tenet of using git. Commit often, perfect later,
by notus 7y ago
I disagree with the usage of githooks for linting and testing. It discourages frequenting committing which is a tenet of using git. Commit often, perfect later, publish once (https://sethrobertson.github.io/GitBestPractices/ https://sethrobertson.github.io/GitBestPractices/).
Your pipeline should be responsible for ensuring things don't make it into the master branch that shouldn't. Run tests and linting on a pull request and make it a requirement for those to pass in order to merge the PR. Otherwise one of two things is going to happen:
1. People will not commit frequently and you will have a commit history that isn't as granular as it should be.
2. People will just bypass the githook check
TBH I think some of this stems from people's fear of rebasing. I've heard so many times, "But it rewrite's the history". Yes, but it's the history on YOUR branch. Nobody should care what you to do your branch and it is yours to perfect. You should want to rewrite the history of your branch in my opinion. If you're committing frequently there will inevitably be some commits you want to squash or fixup.
- paulddraper 7y agoGithooks are the source control version of a database trigger. Aka, sometimes useful, but usually a bad idea.
- philpem 7y agoI agree with you. A better solution would be to use CI to check the branches (so you know what state you're in) and enforce a test and style pass before a branch can be merged to master. I don't know why there's such a fear of rebasing, in a lot of situations it's the right way to go. I don't like squashing though, but that's a personal choice - sometimes excessive use of squash can hide the history of why things developed the way they did, and that can sometimes be very useful information.