.. include:: /Includes.rst.txt .. index:: single: Git; Commit Message Rules single: Commit Message Rules .. _commitmessage: =================================== 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! .. code-block:: none [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 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 :ref:`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 :ref:`Editing the changelog `. .. important:: Whenever your change introduces a breaking change, it is **mandatory** to put `[!!!]` in front of the keyword. `[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 .. sidebar:: The seven rules of a great Git commit message https://chris.beams.io/posts/git-commit/#seven-rules is an excellent guide about how to write good subject lines. - 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 ------------ - :ref:`Deprecations ` must **not** use the breaking Prefix [!!!] - :ref:`Deprecations ` may **only** be of type **[TASK]** or **[FEATURE]** 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! .. code-block:: text :caption: commit message Resolves: #12345 Resolves: #67890 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.: .. code-block:: text :caption: commit message 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.: .. code-block:: text :caption: commit message 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: .. code-block:: text :caption: commit message 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 **main** first and then backport a change if it goes along with our support rules for older versions.. Example: .. code-block:: text :caption: commit message Releases: main, 10.4, 9.5 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: .. code-block:: text :caption: commit message 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 :ref:`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 :ref:`lifeOfAPatch-Reverting-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 :ref:`committemplate`. Bad summary lines examples vs. good examples ============================================ Please note that the following examples are taken from *real commits*. **Example 1** .. code-block:: none [FOLLOWUP][BUGFIX] Remove uglify of jquery-ui/sortable.js should have been: .. code-block:: none [BUGFIX] Remove uglify of jquery-ui/sortable.js **Example 2** .. code-block:: none [BUGFIX] EXT:filelist Cancelling the file exists already modal works now should have been: .. code-block:: none [BUGFIX] Allow cancelling modal that appears when file exists **Example 3** .. code-block:: none Revert "[FEATURE] EXT:form - introduce YAML "imports"" should have been: .. code-block:: none [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** .. code-block:: none [TASK] Revert "Add support for PSR-15 HTTP middlewares" should have been: .. code-block:: none [TASK] Revert "[FEATURE] Add support for PSR-15 HTTP middlewares" **Example 5** .. code-block:: none [TASK] use horizontal ellipsis instead of 3 dots should have been: .. code-block:: none [TASK] Use horizontal ellipsis instead of 3 dots **Example 6** .. code-block:: none [BUGFIX] Element Browser should only render default language pages should have been: .. code-block:: none [BUGFIX] Limit element browser to only render default language pages **Example 7** .. code-block:: none [BUGFIX] D3.js uses basic authentication credentials cached in browser should have been: .. code-block:: none [BUGFIX] Use only basic authentication credentials cached in browser in D3.js **Example 8** .. code-block:: none [DOCS] 1/1 9.1 Documentation should have been: .. code-block:: none [DOCS] Add documentation for version 9.1 (1/1) **Example 9** .. code-block:: none [FEATURE] Option to globally enable redirect hit count should have been: .. code-block:: none [FEATURE] Add option to globally enable redirect hit count **Example 10** .. code-block:: none [TASK] Improved extension configuration API should have been: .. code-block:: none [TASK] Improve extension configuration API **Example 11** .. code-block:: none [BUGFIX] NewContentElementWizardController to NewContentElementController should have been: .. code-block:: none [BUGFIX] Remove recently introduced NewContentElementWizardController **Example 12** .. code-block:: none [BUGFIX] Invalidate session token on creating content element in admin panel Should have been: .. code-block:: none [BUGFIX] Fix backend edit URL in admin panel