Gerrit/Commit message guidelines

The commit message plays an important role in revision control systems. They are the first thing other people will see of your commit.

Subject
The first line of the commit message is known as the subject. It describes the change briefly and helps reviewers to see at a glance what the commit is about.
 * Use the imperative mood (e.g., "Make foo do bar" instead of "[This patch] makes foo do bar" or "[I am] changing foo to do bar").
 * As being a title (not a paragraph) it should not end in a full stop.
 * Optionally prefix it with the changed component.
 * It should be no more than 50 characters (must be less than 80).

Body
Use the body of the commit message to describe your change in detail.
 * Separate the body from the subject with an empty line.


 * Give an overview of why you're committing this change.
 * What the commit changes.
 * Any new design choices made.
 * Areas to focus on for recommendations or to verify correct implementation.
 * Any research you might have done.
 * Bytes are cheap, so just write!
 * Try to make your commit message understandable without external resources (e.g., instead of just giving a URL to a mailing list archive, summarize the relevant points of the discussion).
 * Wrap the body of the message between 70 and 100 characters.


 * Cross-references
 * (For Bugzilla) Add a "Bug: NNNNN" keyword at the end to cross-reference a Bugzilla ticket. This should trigger a "Gerrit Notification Bot" to transition the bug's status to PATCH_TO_REVIEW.
 * (For Phabricator) Add a "Bug: TNNN" keyword at the end to cross-reference a Phabricator Maniphest/task/bug. This should trigger a "Gerrit Notification Bot" to tag the corresponding Maniphest with.
 * (For RT) Add a "RT: NNNN" keyword at the end to cross-reference an RT ticket.
 * Gerrit's  tool will automatically append the "Change-Id: INNN" keyword to new commits.

Example
jquery.badge: Add ability to display the number zero

Cupcake ipsum dolor sit. Amet tart cheesecake tiramisu chocolate cake topping. Icing ice cream sweet roll. Biscuit dragée toffee wypas.

Does not yet address bug 44441 or T176. Follows-up Id5e7cbb1.

Bug: 12345 Bug: T42 Change-Id: I88c5f819c42d9fe1468be6b2cf74413d7d6d6907

Patch set comments
Please do not add patch set-specific comments to the commit message body. Instead, enter patch set-specific comments as Gerrit patch set comments on the specific code lines or in the general patch set comment area.

Subject
Bear in mind that many interfaces use the subject to identify a commit, such as:
 * Gerrit: E-mail notifications, IRC notifications, Search results
 * Gitblit: Commit subject
 * GitHub: Commit history, Commit subject
 * ,  etc.
 * Release notes of Wikimedia deployment branches of MediaWiki
 * and much more!

In all these cases the subject is rendered as plain text. Avoid using Bugzilla, Phabricator or Git references in the subject as they have no meaning in plain text. Instead mention them in the body text and/or as key-value pairs in the footer. When someone views the change in Gerrit this data is parsed (bug references, Git hashes, URLs all become linkified).

Component
You may prefix the subject with a component indicating what area of the code is affected by this commit.

It should be one of the following:
 * Group of php classes (like "uploads", "cache", "database", "resourceloader", "maintenance", "installer", etc.; typically directories in ).
 * Class name (like "Title", "User", "OutputPage", etc.)
 * Module name (like "mediawiki.title", "mediawiki.user", etc.)
 * Keyword affecting multiple areas relating to the type of change (e.g. "doxygen", "test", "phpcs", "qunit", or "travis")

Auto-linking and cross-referencing
Whenever you refer to another commit, use either the SHA-1 of the merged commit, or the Gerrit Change-Id of the changeset in Gerrit (avoid using Gerrit or Gitweb urls). If the commit in question has not been merged yet, use the Gerrit Change-Id instead of the SHA1 because the SHA1 changes every patch set (the SHA1 reference would potentially be a dead end).

Bugzilla
To reference a bug (from our Bugzilla installation) in the commit message mention it inline using the  keyword (lowercase) followed by one space and only the bug number (e.g. " That fixes bug 44441. ")

To express that a commit addresses a bug, add a  footer right above the  : Bug: bugnumber

A bot will automatically notify Bugzilla about a new change set and any significant status changes (being merged, abandoned, etc.). Additionally, the bug's status gets set to. This behaviour is only triggered when a change has the bug linked in the footer using the specified format. If the patch addresses two or more bugs, put each  etc. reference on its own line on the bottom.

Phabricator
To reference a bug (from our Phabricator installation) in the commit message mention it inline using the TNNN notation (e.g. " That fixes T169. ")

To express that a commit addresses a bug, add a  footer right above the  : Bug: T169

A bot will automatically notify Phabricator about a new change set and any significant status changes (being merged, abandoned, etc.). Additionally, the Maniphest will get tagged with. This behaviour is only triggered when a change has the bug linked in the footer using the specified format. If the patch addresses two or more bugs, put each  etc. reference on its own line on the bottom.