committing.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 master 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 master
  28. ===================
  29. Now that you have the code, you should rebase the commits on to the ``master`` 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 master
  44. $ git merge --ff-only upstream/master
  45. $ # Rebase this pull request on to master
  46. $ git checkout pr/xxxx
  47. $ git rebase master
  48. $ # Update master to this commit
  49. $ git checkout master
  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,
  62. in brackets, if they are not a core committer.
  63. For example:
  64. .. code-block:: text
  65. * Fix: Tags added on the multiple image uploader are now saved correctly (Alex Smith)
  66. The release notes for each version contain a more detailed description of each change.
  67. Backwards compatibility notes should also be included.
  68. Large new features or changes should get their own section,
  69. while smaller changes and bug fixes should be grouped together in their own section.
  70. See previous release notes for examples.
  71. The release notes for each version are found in ``docs/releases/x.x.x.rst``.
  72. If the contributor is a new person, and this is their first contribution to Wagtail,
  73. they should be added to the ``CONTRIBUTORS.rst`` list.
  74. Contributors are added in chronological order,
  75. with new contributors added to the bottom of the list.
  76. Use their preferred name.
  77. You can usually find the name of a contributor on their Github profile.
  78. If in doubt, or if their name is not on their profile, ask them how they want to be named.
  79. If the changes to be merged are small enough to be a single commit,
  80. amend this single commit with the additions to
  81. the ``CHANGELOG.txt``, release notes, and contributors:
  82. .. code-block:: console
  83. $ git add CHANGELOG.txt docs/releases/x.x.x.rst CONTRIBUTORS.rst
  84. $ git commit --amend --no-edit
  85. If the changes do not fit in a single commit, make a new commit with the updates to
  86. the ``CHANGELOG.txt``, release notes, and contributors.
  87. The commit message should say ``Release notes for #xxxx``:
  88. .. code-block:: console
  89. $ git add CHANGELOG.txt docs/releases/x.x.x.rst CONTRIBUTORS.rst
  90. $ git commit -m 'Release notes for #xxxx'
  91. Push to master
  92. ==============
  93. The changes are ready to be pushed to ``master`` now.
  94. .. code-block:: console
  95. $ # Check that everything looks OK
  96. $ git log upstream/master..master --oneline
  97. $ git push --dry-run upstream master
  98. $ # Push the commits!
  99. $ git push upstream master
  100. $ git branch -d pr/xxxx
  101. When you have made a mistake
  102. ============================
  103. It's ok! Everyone makes mistakes. If you realise that recent merged changes
  104. have a negative impact, create a new pull request with a revert of the changes
  105. and merge it without waiting for a review. The PR will serve as additional
  106. documentation for the changes, and will run through the CI tests.