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 72 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 followed by a
  single space. This format is rendered correctly by Forge (redmine)
* Use a hanging indent

Resolves: #12346
Related: #12340
Releases: main, 12.4
Change-Id: I<some string generated by the git commit-msg hook>
Copied!

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 "main" 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 in the changelog.
[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 the main branch. See Editing the changelog.
[SECURITY]
Visualizes that a change fixes a security issue. This tag is used by the Security Team.
  • 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

  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.:

    commit message
    Resolves: #12345
    Copied!

    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.:

    commit message
    Resolves: #M12345
    Copied!
  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:

    commit message
    Related: #12345
    Copied!
  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 main first and then backport a change if it goes along with our support rules for older versions.. Example:

    commit message
    Releases: main, 10.4, 9.5
    Copied!

    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:

    commit message
    Depends: ChangeIdOfCorePatch
    Copied!
  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.

This is covered in the Git setup instructions, see Setting up a Commit Message Template.

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
Copied!

should have been:

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

Example 2

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

should have been:

[BUGFIX] Allow cancelling modal that appears when file exists
Copied!

Example 3

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

should have been:

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

Example 4

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

should have been:

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

Example 5

[TASK] use horizontal ellipsis instead of 3 dots
Copied!

should have been:

[TASK] Use horizontal ellipsis instead of 3 dots
Copied!

Example 6

[BUGFIX] Element Browser should only render default language pages
Copied!

should have been:

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

Example 7

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

should have been:

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

Example 8

[DOCS] 1/1 9.1 Documentation
Copied!

should have been:

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

Example 9

[FEATURE] Option to globally enable redirect hit count
Copied!

should have been:

[FEATURE] Add option to globally enable redirect hit count
Copied!

Example 10

[TASK] Improved extension configuration API
Copied!

should have been:

[TASK] Improve extension configuration API
Copied!

Example 11

[BUGFIX] NewContentElementWizardController to NewContentElementController
Copied!

should have been:

[BUGFIX] Remove recently introduced NewContentElementWizardController
Copied!

Example 12

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

Should have been:

[BUGFIX] Fix backend edit URL in admin panel
Copied!