Angular commit message guidelines on every commit

Published on by Marko Šamec
This is a quick tutorial on how to make sure that your developers use proper git commit message and follow certain commit message guidelines. On our projects we are using Angular guidelines. I will not go into details about it here but if you don’t know what that is I recommend reading this first. First and foremost […]

This is a quick tutorial on how to make sure that your developers use proper git commit message and follow certain commit message guidelines. On our projects we are using Angular guidelines. I will not go into details about it here but if you don’t know what that is I recommend reading this first.

First and foremost install ghook npm package. 

npm install ghooks –save-dev

ghook package is an alternative to using .git/hooks allowing you to save commands in your package.json to be called in the appropriate place, like so: 

“config”: {
    “ghooks”: {
        “commit-msg”: “validate-commit-msg”
    }
}

Why not just use .git/hooks? Well because then you have to make sure that every developer on the project has imported proper hooks into his .git repository.

Next you need to install validate-commit-msg package

npm install validate-commit-msg –save-dev

This package implements commit message formats as a git hook, and by entering the default config (mentioned above), our commit messages will adhere to the Angular guidelines.

commit message example

This might take some getting used to, but the benefits of having standards within a team far outweigh the slight learning curve of sticking to conventions such as this.

Having commit message guidelines and enforcing them as standard can help teams.

Further resources:

Posted in:   Tags:  

About the author

Leave a Reply

Your email address will not be published. Required fields are marked *