New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define commit type, and enhance the `CHANGELOG` format #61

Open
Hywan opened this Issue Feb 15, 2017 · 9 comments

Comments

@Hywan
Copy link
Member

Hywan commented Feb 15, 2017

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?

@Hywan Hywan added this to the Roadmap for 2017 milestone Feb 15, 2017

@Hywan Hywan self-assigned this Feb 15, 2017

@Hywan Hywan changed the title Define a new commit message format, and a new CHANGELOG format Define a better commit message format, and a new CHANGELOG format Feb 16, 2017

@Hywan Hywan changed the title Define a better commit message format, and a new CHANGELOG format Define commit type, and enhance the `CHANGELOG` format Feb 16, 2017

@Pierozi

This comment has been minimized.

Copy link
Member

Pierozi commented Mar 7, 2017

👍 Beautiful changelog generate, can't agree more !
Did you know if a github bot exist to check the commit message format ?

@Hywan

This comment has been minimized.

Copy link
Member

Hywan commented Mar 7, 2017

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?

@Pierozi

This comment has been minimized.

Copy link
Member

Pierozi commented Mar 7, 2017

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.

@vonglasow

This comment has been minimized.

Copy link
Member

vonglasow commented Mar 7, 2017

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.

@Pierozi

This comment has been minimized.

Copy link
Member

Pierozi commented Mar 8, 2017

Yep i like grumphp, that could be enough. Great idea!

@CircleCode

This comment has been minimized.

Copy link
Member

CircleCode commented Mar 8, 2017

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.

@Hywan

This comment has been minimized.

Copy link
Member

Hywan commented Mar 8, 2017

@CircleCode I would highly go on your side.

Should a dry-run mode on hoa devtools:snapshot --only-changelog --dry-run would be adequate?

@Pierozi

This comment has been minimized.

Copy link
Member

Pierozi commented Mar 8, 2017

🤔 Ok, that could be a part of our Contributor guide, like we ask to run CS before submitting PR.
that's make sense

@vonglasow

This comment has been minimized.

Copy link
Member

vonglasow commented Mar 8, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment