Answer the question
In order to leave comments, you need to log in
How to make a Git-hook to force a correct commit message format?
I want the repository to be unable to have commits that are not related to the issue in the tracker. The commit should not pass according to the format.
An example of a valid message: feat: 123123123: fixed missing stream closing
.
"feat:" is needed for semantic versioning .
"123123123" - needed for correct auto-generation of the changelog.
What is the best way to do this? Preferably based on pre-commit .
Answer the question
In order to leave comments, you need to log in
In the end, it turned out to be the easiest thing to do a hook for the pre-commit system.
This option was chosen due to the fact that pre-commit has already solved for me all the compatibility problems of hooks and the operating system, and also because it has other interesting hooks that I will use on the project. For example, blocking the commit of large files.
https://github.com/snowindy/msg-rules-enforcement-hook
Here you need a commit-msg hook. Here is an article that perfectly describes what you want to do https://habr.com/ru/company/dins/blog/584562/ .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question