xref: /arm-trusted-firmware/docs/process/commit-style.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluCommit Style
2*91f16700Schasinglulu============
3*91f16700Schasinglulu
4*91f16700SchasingluluWhen writing commit messages, please think carefully about the purpose and scope
5*91f16700Schasingluluof the change you are making: describe briefly what the change does, and
6*91f16700Schasingluludescribe in detail why it does it. This helps to ensure that changes to the
7*91f16700Schasinglulucode-base are transparent and approachable to reviewers, and it allows us to
8*91f16700Schasinglulukeep a more accurate changelog. You may use Markdown in commit messages.
9*91f16700Schasinglulu
10*91f16700SchasingluluA good commit message provides all the background information needed for
11*91f16700Schasinglulureviewers to understand the intent and rationale of the patch. This information
12*91f16700Schasingluluis also useful for future reference.
13*91f16700Schasinglulu
14*91f16700SchasingluluFor example:
15*91f16700Schasinglulu
16*91f16700Schasinglulu- What does the patch do?
17*91f16700Schasinglulu- What motivated it?
18*91f16700Schasinglulu- What impact does it have?
19*91f16700Schasinglulu- How was it tested?
20*91f16700Schasinglulu- Have alternatives been considered? Why did you choose this approach over
21*91f16700Schasinglulu  another one?
22*91f16700Schasinglulu- If it fixes an `issue`_, include a reference.
23*91f16700Schasinglulu
24*91f16700Schasinglulu|TF-A| follows the `Conventional Commits`_ specification. All commits to the
25*91f16700Schasinglulumain repository are expected to adhere to these guidelines, so it is
26*91f16700Schasinglulu**strongly** recommended that you read at least the `quick summary`_ of the
27*91f16700Schasingluluspecification.
28*91f16700Schasinglulu
29*91f16700SchasingluluTo briefly summarize, commit messages are expected to be of the form:
30*91f16700Schasinglulu
31*91f16700Schasinglulu.. code::
32*91f16700Schasinglulu
33*91f16700Schasinglulu    <type>[optional scope]: <description>
34*91f16700Schasinglulu
35*91f16700Schasinglulu    [optional body]
36*91f16700Schasinglulu
37*91f16700Schasinglulu    [optional footer(s)]
38*91f16700Schasinglulu
39*91f16700SchasingluluThe following example commit message demonstrates the use of the
40*91f16700Schasinglulu``refactor`` type and the ``amu`` scope:
41*91f16700Schasinglulu
42*91f16700Schasinglulu.. code::
43*91f16700Schasinglulu
44*91f16700Schasinglulu    refactor(amu): factor out register accesses
45*91f16700Schasinglulu
46*91f16700Schasinglulu    This change introduces a small set of register getters and setters to
47*91f16700Schasinglulu    avoid having to repeatedly mask and shift in complex code.
48*91f16700Schasinglulu
49*91f16700Schasinglulu    Change-Id: Ia372f60c5efb924cd6eeceb75112e635ad13d942
50*91f16700Schasinglulu    Signed-off-by: Chris Kay <chris.kay@arm.com>
51*91f16700Schasinglulu
52*91f16700SchasingluluThe following `types` are permissible and are strictly enforced:
53*91f16700Schasinglulu
54*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
55*91f16700Schasinglulu| Scope        | Description                                                   |
56*91f16700Schasinglulu+==============+===============================================================+
57*91f16700Schasinglulu| ``feat``     | A new feature                                                 |
58*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
59*91f16700Schasinglulu| ``fix``      | A bug fix                                                     |
60*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
61*91f16700Schasinglulu| ``build``    | Changes that affect the build system or external dependencies |
62*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
63*91f16700Schasinglulu| ``ci``       | Changes to our CI configuration files and scripts             |
64*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
65*91f16700Schasinglulu| ``docs``     | Documentation-only changes                                    |
66*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
67*91f16700Schasinglulu| ``perf``     | A code change that improves performance                       |
68*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
69*91f16700Schasinglulu| ``refactor`` | A code change that neither fixes a bug nor adds a feature     |
70*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
71*91f16700Schasinglulu| ``revert``   | Changes that revert a previous change                         |
72*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
73*91f16700Schasinglulu| ``style``    | Changes that do not affect the meaning of the code            |
74*91f16700Schasinglulu|              | (white-space, formatting, missing semi-colons, etc.)          |
75*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
76*91f16700Schasinglulu| ``test``     | Adding missing tests or correcting existing tests             |
77*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
78*91f16700Schasinglulu| ``chore``    | Any other change                                              |
79*91f16700Schasinglulu+--------------+---------------------------------------------------------------+
80*91f16700Schasinglulu
81*91f16700SchasingluluThe permissible `scopes` are more flexible, and we maintain a list of them in
82*91f16700Schasingluluour :download:`changelog configuration file <../../changelog.yaml>`. Scopes in
83*91f16700Schasingluluthis file are organized by their changelog section, where each changelog section
84*91f16700Schasingluluhas a single scope that is considered to be blessed, and possibly several
85*91f16700Schasingluludeprecated scopes. Please avoid using deprecated scopes.
86*91f16700Schasinglulu
87*91f16700SchasingluluWhile we don't enforce scopes strictly, we do ask that commits use these if they
88*91f16700Schasinglulucan, or add their own if no appropriate one exists (see :ref:`Adding Scopes`).
89*91f16700Schasinglulu
90*91f16700SchasingluluIt's highly recommended that you use the tooling installed by the optional steps
91*91f16700Schasingluluin the :ref:`prerequisites <Prerequisites>` guide to validate commit messages
92*91f16700Schasinglululocally, as commitlint reports a live list of the acceptable scopes.
93*91f16700Schasinglulu
94*91f16700Schasinglulu.. _Adding Scopes:
95*91f16700Schasinglulu
96*91f16700SchasingluluAdding Scopes
97*91f16700Schasinglulu-------------
98*91f16700Schasinglulu
99*91f16700SchasingluluScopes that are not present in the changelog configuration file are considered
100*91f16700Schasingluluto be deprecated, and should be avoided. If you are adding a new component that
101*91f16700Schasingluludoes not yet have a designated scope, please add one.
102*91f16700Schasinglulu
103*91f16700SchasingluluFor example, if you are adding or making modifications to `Foo`'s latest and
104*91f16700Schasinglulugreatest new platform `Bar` then you would add it to the `Platforms` changelog
105*91f16700Schasinglulusub-section, and the hierarchy should look something like this:
106*91f16700Schasinglulu
107*91f16700Schasinglulu.. code:: yaml
108*91f16700Schasinglulu
109*91f16700Schasinglulu    - title: Platforms
110*91f16700Schasinglulu
111*91f16700Schasinglulu      subsections:
112*91f16700Schasinglulu        - title: Foo
113*91f16700Schasinglulu          scope: foo
114*91f16700Schasinglulu
115*91f16700Schasinglulu          subsections:
116*91f16700Schasinglulu            - title: Bar
117*91f16700Schasinglulu              scope: bar
118*91f16700Schasinglulu
119*91f16700SchasingluluWhen creating new scopes, try to keep them short and succinct, and use kebab
120*91f16700Schasinglulucase (``this-is-kebab-case``). Components with a product name (i.e. most
121*91f16700Schasingluluplatforms and some drivers) should use that name (e.g. ``gic600ae``,
122*91f16700Schasinglulu``flexspi``, ``stpmic1``), otherwise use a name that uniquely represents the
123*91f16700Schasinglulucomponent (e.g. ``marvell-comphy-3700``, ``rcar3-drivers``, ``a3720-uart``).
124*91f16700Schasinglulu
125*91f16700SchasingluluMandated Trailers
126*91f16700Schasinglulu-----------------
127*91f16700Schasinglulu
128*91f16700SchasingluluCommits are expected to be signed off with the ``Signed-off-by:`` trailer using
129*91f16700Schasingluluyour real name and email address. You can do this automatically by committing
130*91f16700Schasingluluwith Git's ``-s`` flag. By adding this line the contributor certifies the
131*91f16700Schasinglulucontribution is made under the terms of the :download:`Developer Certificate of
132*91f16700SchasingluluOrigin <../../dco.txt>`.
133*91f16700Schasinglulu
134*91f16700SchasingluluThere may be multiple ``Signed-off-by:`` lines depending on the history of the
135*91f16700Schasinglulupatch, but one **must** be the committer. More details may be found in the
136*91f16700Schasinglulu`Gerrit Signed-off-by Lines guidelines`_.
137*91f16700Schasinglulu
138*91f16700SchasingluluEnsure that each commit also has a unique ``Change-Id:`` line. If you have
139*91f16700Schasinglulufollowed optional steps in the prerequisites to either install the Node.js tools
140*91f16700Schasingluluor clone the repository using the "`Clone with commit-msg hook`" clone method,
141*91f16700Schasingluluthen this should be done automatically for you.
142*91f16700Schasinglulu
143*91f16700SchasingluluMore details may be found in the `Gerrit Change-Ids documentation`_.
144*91f16700Schasinglulu
145*91f16700Schasinglulu--------------
146*91f16700Schasinglulu
147*91f16700Schasinglulu*Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.*
148*91f16700Schasinglulu
149*91f16700Schasinglulu.. _Conventional Commits: https://www.conventionalcommits.org/en/v1.0.0
150*91f16700Schasinglulu.. _Gerrit Change-Ids documentation: https://review.trustedfirmware.org/Documentation/user-changeid.html
151*91f16700Schasinglulu.. _Gerrit Signed-off-by Lines guidelines: https://review.trustedfirmware.org/Documentation/user-signedoffby.html
152*91f16700Schasinglulu.. _issue: https://developer.trustedfirmware.org/project/board/1/
153*91f16700Schasinglulu.. _quick summary: https://www.conventionalcommits.org/en/v1.0.0/#summary
154