Central
Central copied to clipboard
Define commit type, and enhance the `CHANGELOG` format
Hello fellow @hoaproject/hoackers and users!
Introduction
Actual commit messages in Hoa are really great. They are detailed, meaningful, reviewed, and comprehensive. The commit title is always: scope: title
. However, when generating the CHANGELOG.md
file, this is hard to see what is a bug fix or a new feature.
Goal
Import the concept of “commit type” from the Angular commit message guideline.
To quote it:
We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate the AngularJS change log.
The commit message formatting can be added using a typical git workflow or through the use of a CLI wizard (Commitizen). To use the wizard, run
yarn run commit
in your terminal after staging your changes in git.Commit Message Format
Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:
<type>(<scope>): <subject> <BLANK LINE> <body> <BLANK LINE> <footer>
The header is mandatory and the scope of the header is optional.
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools.
Revert
If the commit reverts a previous commit, it should begin with
revert:
, followed by the header of the reverted commit. In the body it should say:This reverts commit <hash>.
, where the hash is the SHA of the commit being reverted.Type
Must be one of the following:
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing or correcting existing tests
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
Scope
The scope could be anything specifying place of the commit change. For example
$location
,$browser
,$compile
,$rootScope
,ngHref
,ngClick
,ngView
, etc...You can use
*
when the change affects more than a single scope.Subject
The subject contains succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize first letter
- no dot (.) at the end
Body
Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.
Footer
The footer should contain any information about Breaking Changes and is also the place to [reference GitHub issues that this commit closes][closing-issues].
Breaking Changes should start with the word
BREAKING CHANGE:
with a space or two newlines. The rest of the commit message is then used for this.A detailed explanation can be found in this [document][commit-message-format].
Not everything is useful. We are mostly concerned about the “commit type”.
Differences with the current format
The “commit type” is the only main difference, and this is what I would like to “import” in our format. The goal is to generate a CHANGELOG
as suggested by http://keepachangelog.com/en/0.3.0/, so with the “Added”, “Bug fixes”, “Removed“ Sections, and the date of the release (already given by our Rust Release snapshot format, but anyway, we should give it a try).
Commit types
I would like to introduce the following commit types:
-
feat
for a new feature, -
fix
for a bug fix, -
test
for a test modification, -
doc
for a documentation modification, -
chore
to replace the “Quality” type, -
undef
for anything else, must not be used, so should we introduce it?
Example
In the Angular commit message guideline, they propose this syntax: type(scope): title
. In Hoa, we use scope: title
. The colon is a separator. However, the commit type will reduce the size of the title (remember that we have only 50 characters for the whole line!). With the type(scope)
we no longer need a separator, so I propose type(scope) title
, like
-
feat(permission) Search backward bla bla.
, -
fix(user) `getName` is incorrectly computing its value.
, - …
Will produce:
2.17.16.02
New features
Permission
- Search backward bla bla (Ivan Enderlin, date, bla).
Bug fixes
User
getName
is incorrectly computing its value (Ivan Enderlin, date, bla).
Thoughts?
:+1: Beautiful changelog generate, can't agree more ! Did you know if a github bot exist to check the commit message format ?
Github is a mirror for us, just like Gitlab or Pikacode. So we can add a hook on our own Git server at https://git.hoa-project.net. Thoughts?
Yup but we use github to accept pull request. same as travis build. idea is to have PR blocked until commit message fit the expected.
The best way is to have it on our side to be sure we can't commit something with wrong message. We can use for that grumphp or we can inspire from it to be sure we have something equal for each library. Another thing is to provide a template (if necessary) to pre-fill the commit message.
Regarding the syntax it may be difficult to define the scope so only the prefix as fix:
or feat:
could be used the scope will be explain in title and commit message after.
As this verification could be bypassed we must add it also on our side. But if we restrict it to be consistent about some format or anything else we should provide an help to use it.
@Pierozi we can add in travis build some verification to be sure it's ok.
Yep i like grumphp, that could be enough. Great idea!
Be careful, generally speaking, preventing someone to commit (even if this is to increase code quality) is considered a bad practice: git concept is commit as often and as quickly as you need. Additionally, since every commit can be rewritten, we do not need to ensure its consistency while it is on the developer computer. I'd rather suggest a tool that could be launched manually (by default, it would check every commit between head and upstream branch), for which we can choose the range to analyze. This tool would then be launched on before push on the client side, and on before receive on server side.
@CircleCode I would highly go on your side.
Should a dry-run mode on hoa devtools:snapshot --only-changelog --dry-run
would be adequate?
:thinking: Ok, that could be a part of our Contributor guide, like we ask to run CS before submitting PR. that's make sense
I am agree with @CircleCode but this not means we should not provide a kind of tools (helper). We should provide a way to be able to do it on our side. In my case, I prefer to have an error when I try to commit and which explain what I have missed than waiting few weeks for a review and tell me the commit message have a wrong format.
Using Grumphp will force contributors to respect our guideline it's maybe too restrictif, so we should not force people to use it but recommend it. And we should provide an easy way to implement it.