6

We are on Java Spring project and we need to validate commit message if it is suitable to commit convention which is expressed by Commit Guideline or Conventional Commits

I know there is a git hook(commit-msg) for this but I don't think I am able to check all conditions on above links and if I write these conditions I am not sure everyone who pulls my changes will be effected with these changes.

What I want is something like Husky for Java projects.

3 Answers 3

1

am not sure everyone who pulls my changes will be effected with these changes

You're correct. They'll need to install any client side hooks for them to take effect.

You could consider a Server Side Hook if your hosting provider supports it.

I don't think I am able to check all conditions on above links

How you implement your checks are a separate issue. I'm sure you can grep / sed / awk your way to a functional linter for your commit messages.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer, I know server side hooks but client hook is better option for me.
1

Late in the game, but perhaps still useful. If you can code in a friendly language (Python, NodeJS ...) your validation, perhaps using regex, you just need to call it when needed.

Then, you can make use of a git hook management tool to make your life (and team life) better, like https://pypi.org/project/hooks4git

Hope this helps.

Comments

1

Unfortunately, there's no well-known tool for managing git hooks in Java projects like there is Husky for JS.

In my team, we created a commit-msg git hook with bash. You can see the source code. We used bash because we wanted it to be language agnostic.

1 Comment

surely you can create a global library to install it via husky am I right?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.