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