Commit Message rules for TYPO3 CMS

Since we strive to automate a lot of things the commit message plays an important role in order to be able to automate.

Git and related tools work best when following a certain guideline for commit messages. A deeper introduction on git revision log conventions is helpful to understand the scope.

Here is an example of a final commit message. The change-id will be generated by the commit-hook. Do not set the change-id on your first commit!

[BUGFIX] Introduce some serious fixing

Most importantly, describe what is changed with the commit
and not what is has not been working
(that is part of the bug report already).

More detailed explanatory text, if necessary. Wrap it to 74 characters.
The first line is treated as the subject of the commit message and
the rest of the text as the body.  The blank line separating the
subject from the body is critical (unless you omit the body entirely);
tools like git rebase can get confused if you run the two together.

Write your commit message in the '''imperative present tense'''
("Fix bug", not "Fixed bug"). This convention matches up with generated
commit messages by commands like git merge and git revert.

Help others to understand what you did (Motivation for the change?
Whats the difference to the previous version?), but keep it simple.

Problem description as well as testing and/or reproduction instructions
shall be part of the Forge ticket referenced below.
The commit message solely describes '''what is changed'''.

* Bullet points are okay, too
* An asterisk is used for the bullet, it can be preceded by a single
  space. This format is rendered correctly by Forge (redmine)
* Use a hanging indent

Resolves: #12346
Related: #12340
Releases: master, 6.2
Change-Id: I<some string generated by the git commit-msg hook>

You can see that a commit message consists of several parts, let's go over them step by step:

Summary line (first line)

A summary line starts with a keyword and a brief summary of what the change does. Make sure to describe how the behavior is now, not how it used to be - in the end, telling someone what was broken doesn't help anyone, you want to tell what is working now :)

  • Prefix the line with a keyword: [BUGFIX], [FEATURE], [TASK] or [DOCS].

Possible keywords are:

[BUGFIX]
A fix for a bug.
[FEATURE]
A new feature (also small additions). Most likely it will be an added feature, but it could also be removed. Features may exclusively be targeted for the "master" branch of TYPO3 CMS, because no new features are allowed in older branches. Exceptions to this have to be discussed on a case-to-case basis with the designated release managers. Features have to be documented according to TYPO3 CMS Important Changes Documentation HowTo .
[DOCS]
This tag is used for changes regarding the documentation.
[TASK]
Anything not covered by the above categories. E.g. Refactoring of a component

Additionally other flags should be added under certain circumstances:

[!!!]

Breaking change. After this patch, something works different than before and the user / admin / extension developer will have to change something. Has to be documented accordingly and should only be targeted for master branch. See TYPO3 CMS Important Changes Documentation HowTo.

Important

Whenever your change introduces a breaking change, it is mandatory to put [!!!] in front of the keyword.

[WIP]
Work In Progress. This flag is not mandatory and must be added before any other keywords; will be removed, once the final version of a change is available. Changes marked WIP are never merged. An example could be: [WIP][TASK] Write some neat comment.

Note that if you want to add a breaking feature which is still work in progress, you would use [WIP][!!!][FEATURE] Transform Lead to Gold as your summary line. This way it is very easy to see the WIP state; that it is also breaking doesn't really matter at this point.

[SECURITY]
Visualizes that a change fixes a security issue. This tag is used by the Security Team.

Important

In case you found a security issue, always get in touch with the Security Team first! Never post information about security vulnerabilities in a public place such as Slack or push patches that disclose information about vulnerabilities.

  • Keep the whole line below 52 characters if possible, but below 80 in any case
  • It is very important that the message is written in imperative mood; that means that it must be written as if you are giving a command or an instruction, since a commit is a set of instructions for how to go from a previous state to the new state and the commit message should describe this process. This convention matches up with generated commit messages by commands like git merge and git revert. If in doubt, the golden rule to follow is very simple: Review your subject lines, and apply the following words in front of it:

if applied, this commit will **"your subject line here"**

For example (you will find some more examples later):

If applied, this commit will **Invalid session token on creating content element in admin panel** Does not make any sense.

If applied, this commit will **"Fix backend edit URL in admin panel"** Reads nicely and explains what happened

  • After the keyword, make sure to start the summary with a capital letter.
  • Avoid using EXT:somesystemextension in the commit subject: looks ugly and is redundant when you look at what code changed.
  • In case of reverting a previous commit, basically you should just prepend [TASK] to the message automatically generated by a git revert. For example, in case of reverting a feature you would use: [TASK] Revert "[FEATURE] Transform Lead to Gold"

Deprecations

Some examples of topic descriptions

[BUGFIX] Throw HttpStatusExceptions in BackendController

[FEATURE] Add option to hide BE search box in list mod

[!!!][FEATURE] Implement new BE login form service

[!!!][TASK] Replace Foo API with new approach

[SECURITY] Escape record title in RecordsOverview

Note: The [!!!] prefix is added at the very beginning of the line, so it doesn't get overlooked.

Description (Message body)

Here you can go into detail about the how and why of the change. It should be brief, but yet descriptive so people reviewing your change get an idea what they need to look out for

  • Describe the fix/change introduced by the Change Request. (The problem is already described in the Forge ticket.)
  • Keep it simple and don't repeat information that is already part of the issue tracker. Especially avoid "How to reproduce" part. At most, try to explain the change itself, if it is not already clear by reading the diff. Do not repeat the code change itself in the body text.
  • Wrap the lines after 72 characters manually

Relationships

Important

  1. The space after the colon (:) is mandatory. Otherwise the system will not properly update forge.
  2. If you have multiple resolved or related issues, use one line for each issue number. Do not separate them by comma or alike!
  1. Resolves: You need to reference an issue on Forge here simply by adding #[ISSUE_NUMBER]. For features and tasks, it closes the issue on merge.:

    Resolves: #12345
    

    Historical : Some issues from the time since the introduction of GIT (March 1st 2011) and the migration of the bug tracker to Forge (March 29th 2011), still refer to Mantis bug tracker numbers, with a prefix the number with an M , i.e.:

    Resolves: #M12345
    
  2. Related: Other issues related to this change which are not resolved (for all types, it simply adds a relation, no closing). You need to reference an issue on Forge by just adding the issue number like in:

    Related: #12345
    
  3. Releases: This is a comma separated list of the target versions you intend to apply this fix on. In general, we always fix things on master first and then backport a change if it goes along with our support rules for older versions.. Example:

    Releases: master, 7.6, 6.2
    

    Always make sure the target version does indeed exist, when in doubt, as in the coredev channel on Slack.

  4. Depends For TYPO3 documentation patches. Refer to the corresponding TYPO3 Core patch:

    Depends: ChangeIdOfCorePatch
    
  5. Change-Id: Do not write or change this line yourself. But keep the line once it exists.

    The change id is a randomly generated unique ID that identifies this change in Gerrit. The Change-Id line is automatically added by our pre-commit hook. The commit hook is executed when you have finished editing and save the commit message.

    Attention: Be sure to keep the existing Change-Id when adding a new patchset to an existing review. Use git commit --amend to do so.

Reverting patches

If there's the need to revert a patch, please add this information to the commit message:

  1. Add a Resolves-line for the ticket that is giving the reason for the revert.
  2. Add a Reverts-line for the ticket that belongs to the original patch.

You will find more information about the life cycle of a patch here Revert patches.

Commit Template

You can use a custom template for automatically generating a commit message with the basics. When editing the commit message during a commit, you can then add the necessary information.

This is a sample template:

[BUGFIX|TASK|FEATURE]

Resolves: #
Releases: master, 8.7

Put this in a file, for example ~/.gitmessage.txt, and then configure it as template:

git config --global commit.template ~/.gitmessage.txt

This will add the template to your global git configuration (stored for your user, e.g. in ~/.gitconfig). You may not want to do this, because then the template will always be used for git commit, not only for TYPO3 projects.

In this case, you can set the template only for the current TYPO3 repository. That means, the command has to be repeated whenever you create a new TYPO3 repository.

git config --local commit.template ~/.gitmessage.txt

Bad summary lines examples vs. good examples

Please note that the following examples are taken from real commits.

Example 1

[FOLLOWUP][BUGFIX] Remove uglify of jquery-ui/sortable.js

should have been:

[BUGFIX] Remove uglify of jquery-ui/sortable.js

Example 2

[BUGFIX] EXT:filelist Cancelling the file exists already modal works now

should have been:

[BUGFIX] Allow cancelling modal that appears when file exists

Example 3

Revert "[FEATURE] EXT:form - introduce YAML "imports""

should have been:

[TASK] Revert "[FEATURE] introduce YAML "imports""

Note

Please note that in this case the subject of the commit to revert was poorly written,too! This required some additional adjustment..

Example 4

[TASK] Revert "Add support for PSR-15 HTTP middlewares"

should have been:

[TASK] Revert "[FEATURE] Add support for PSR-15 HTTP middlewares"

Example 5

[TASK] use horizontal ellipsis instead of 3 dots

should have been:

[TASK] Use horizontal ellipsis instead of 3 dots

Example 6

[BUGFIX] Element Browser should only render default language pages

should have been:

[BUGFIX] Limit element browser to only render default language pages

Example 7

[BUGFIX] D3.js uses basic authentication credentials cached in browser

should have been:

[BUGFIX] Use only basic authentication credentials cached in browser in D3.js

Example 8

[DOCS] 1/1 9.1 Documentation

should have been:

[DOCS] Add documentation for version 9.1 (1/1)

Example 9

[FEATURE] Option to globally enable redirect hit count

should have been:

[FEATURE] Add option to globally enable redirect hit count

Example 10

[TASK] Improved extension configuration API

should have been:

[TASK] Improve extension configuration API

Example 11

[BUGFIX] NewContentElementWizardController to NewContentElementController

should have been:

[BUGFIX] Remove recently introduced NewContentElementWizardController

Example 12

[BUGFIX] Invalidate session token on creating content element in admin panel

Should have been:

[BUGFIX] Fix backend edit URL in admin panel