commit-style.rst 6.9 KB

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