committing.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. ===============
  2. Committing code
  3. ===============
  4. **This section is for the core team of Wagtail, or for anyone interested in the process of getting code committed to Wagtail.**
  5. Code should only be committed after it has been reviewed
  6. by at least one other reviewer or committer,
  7. unless the change is a small documentation change or fixing a typo.
  8. If additional code changes are made after the review, it is OK to commit them
  9. without further review if they are uncontroversial and small enough that
  10. there is minimal chance of introducing new bugs.
  11. Most code contributions will be in the form of pull requests from Github.
  12. Pull requests should not be merged from Github, apart from small documentation fixes,
  13. which can be merged with the 'Squash and merge' option. Instead, the code should
  14. be checked out by a committer locally, the changes examined and rebased,
  15. the ``CHANGELOG.txt`` and release notes updated,
  16. and finally the code should be pushed to the ``main`` branch.
  17. This process is covered in more detail below.
  18. Check out the code locally
  19. ==========================
  20. If the code has been submitted as a pull request,
  21. you should fetch the changes and check them out in your Wagtail repository.
  22. A simple way to do this is by adding the following ``git`` alias to your ``~/.gitconfig`` (assuming ``upstream`` is ``wagtail/wagtail``):
  23. .. code-block:: text
  24. [alias]
  25. pr = !sh -c \"git fetch upstream pull/${1}/head:pr/${1} && git checkout pr/${1}\"
  26. Now you can check out pull request number ``xxxx`` by running ``git pr xxxx``.
  27. Rebase on to ``main``
  28. =====================
  29. Now that you have the code, you should rebase the commits on to the ``main`` branch.
  30. Rebasing is preferred over merging,
  31. as merge commits make the commit history harder to read for small changes.
  32. You can fix up any small mistakes in the commits,
  33. such as typos and formatting, as part of the rebase.
  34. ``git rebase --interactive`` is an excellent tool for this job.
  35. Ideally, use this as an opportunity to squash the changes to a few commits, so
  36. each commit is making a single meaningful change (and not breaking anything).
  37. If this is not possible because of the nature of the changes, it's acceptable
  38. to either squash into a commit or leave all commits unsquashed,
  39. depending on which will be more readable in the commit history.
  40. .. code-block:: console
  41. $ # Get the latest commits from Wagtail
  42. $ git fetch upstream
  43. $ git checkout main
  44. $ git merge --ff-only upstream/main
  45. $ # Rebase this pull request on to main
  46. $ git checkout pr/xxxx
  47. $ git rebase main
  48. $ # Update main to this commit
  49. $ git checkout main
  50. $ git merge --ff-only pr/xxxx
  51. Update ``CHANGELOG.txt`` and release notes
  52. ==========================================
  53. .. note::
  54. This should only be done by core committers, once the changes have been reviewed and accepted.
  55. Every significant change to Wagtail should get an entry in the ``CHANGELOG.txt``,
  56. and the release notes for the current version.
  57. The ``CHANGELOG.txt`` contains a short summary of each new feature, refactoring, or bug fix in each release.
  58. Each summary should be a single line.
  59. Bug fixes should be grouped together at the end of the list for each release,
  60. and be prefixed with "Fix:".
  61. The name of the contributor should be added at the end of the summary, in brackets.
  62. For example:
  63. .. code-block:: text
  64. * Fix: Tags added on the multiple image uploader are now saved correctly (Alex Smith)
  65. The release notes for each version contain a more detailed description of each change.
  66. Backwards compatibility notes should also be included.
  67. Large new features or changes should get their own section,
  68. while smaller changes and bug fixes should be grouped together in their own section.
  69. See previous release notes for examples.
  70. The release notes for each version are found in ``docs/releases/x.x.x.rst``.
  71. If the contributor is a new person, and this is their first contribution to Wagtail,
  72. they should be added to the ``CONTRIBUTORS.rst`` list.
  73. Contributors are added in chronological order,
  74. with new contributors added to the bottom of the list.
  75. Use their preferred name.
  76. You can usually find the name of a contributor on their Github profile.
  77. If in doubt, or if their name is not on their profile, ask them how they want to be named.
  78. If the changes to be merged are small enough to be a single commit,
  79. amend this single commit with the additions to
  80. the ``CHANGELOG.txt``, release notes, and contributors:
  81. .. code-block:: console
  82. $ git add CHANGELOG.txt docs/releases/x.x.x.rst CONTRIBUTORS.rst
  83. $ git commit --amend --no-edit
  84. If the changes do not fit in a single commit, make a new commit with the updates to
  85. the ``CHANGELOG.txt``, release notes, and contributors.
  86. The commit message should say ``Release notes for #xxxx``:
  87. .. code-block:: console
  88. $ git add CHANGELOG.txt docs/releases/x.x.x.rst CONTRIBUTORS.rst
  89. $ git commit -m 'Release notes for #xxxx'
  90. Push to ``main``
  91. ================
  92. The changes are ready to be pushed to ``main`` now.
  93. .. code-block:: console
  94. $ # Check that everything looks OK
  95. $ git log upstream/main..main --oneline
  96. $ git push --dry-run upstream main
  97. $ # Push the commits!
  98. $ git push upstream main
  99. $ git branch -d pr/xxxx
  100. When you have made a mistake
  101. ============================
  102. It's ok! Everyone makes mistakes. If you realise that recent merged changes
  103. have a negative impact, create a new pull request with a revert of the changes
  104. and merge it without waiting for a review. The PR will serve as additional
  105. documentation for the changes, and will run through the CI tests.
  106. Add commits to someone else's pull request
  107. ==========================================
  108. Github users with write access to wagtail/wagtail (core members) can add
  109. commits to the pull request branch of the contributor.
  110. Given that the contributor username is johndoe and his pull request branch is called foo:
  111. .. code-block:: console
  112. $ git clone git@github.com:wagtail/wagtail.git
  113. $ cd wagtail
  114. $ git remote add johndoe git@github.com:johndoe/wagtail.git
  115. $ git fetch johndoe foo
  116. $ git checkout johndoe/foo
  117. # Make changes
  118. # Commit changes
  119. $ git push johndoe HEAD:foo