submitting-patches.txt 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. ==================
  2. Submitting patches
  3. ==================
  4. We're always grateful for patches to Django's code. Indeed, bug reports
  5. with associated patches will get fixed *far* more quickly than those
  6. without patches.
  7. Typo fixes and trivial documentation changes
  8. --------------------------------------------
  9. If you are fixing a really trivial issue, for example changing a word in the
  10. documentation, the preferred way to provide the patch is using GitHub pull
  11. requests without a Trac ticket. Trac tickets are still acceptable.
  12. See the :doc:`working-with-git` for more details on how to use pull requests.
  13. "Claiming" tickets
  14. ------------------
  15. In an open-source project with hundreds of contributors around the world, it's
  16. important to manage communication efficiently so that work doesn't get
  17. duplicated and contributors can be as effective as possible. Hence, our policy
  18. is for contributors to "claim" tickets in order to let other developers know
  19. that a particular bug or feature is being worked on.
  20. If you have identified a contribution you want to make and you're capable of
  21. fixing it (as measured by your coding ability, knowledge of Django internals
  22. and time availability), claim it by following these steps:
  23. * `Create an account`_ to use in our ticket system. If you have an account
  24. but have forgotten your password, you can reset it using the
  25. `password reset page`_.
  26. * If a ticket for this issue doesn't exist yet, create one in our
  27. `ticket tracker`_.
  28. * If a ticket for this issue already exists, make sure nobody else has
  29. claimed it. To do this, look at the "Assigned to" section of the ticket.
  30. If it's assigned to "nobody," then it's available to be claimed.
  31. Otherwise, somebody else is working on this ticket, and you either find
  32. another bug/feature to work on, or contact the developer working on the
  33. ticket to offer your help.
  34. * Log into your account, if you haven't already, by clicking "Login" in
  35. the upper right of the ticket page.
  36. * Claim the ticket:
  37. 1. click the "accept" radio button under "Action" near the bottom of the
  38. page,
  39. 2. then click "Submit changes."
  40. .. _Create an account: https://www.djangoproject.com/accounts/register/
  41. .. _password reset page: https://www.djangoproject.com/accounts/password/reset/
  42. Ticket claimers' responsibility
  43. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44. Once you've claimed a ticket, you have a responsibility to work on that ticket
  45. in a reasonably timely fashion. If you don't have time to work on it, either
  46. unclaim it or don't claim it in the first place!
  47. If there's no sign of progress on a particular claimed ticket for a week or
  48. two, another developer may ask you to relinquish the ticket claim so that it's
  49. no longer monopolized and somebody else can claim it.
  50. If you've claimed a ticket and it's taking a long time (days or weeks) to code,
  51. keep everybody updated by posting comments on the ticket. If you don't provide
  52. regular updates, and you don't respond to a request for a progress report,
  53. your claim on the ticket may be revoked. As always, more communication is
  54. better than less communication!
  55. Which tickets should be claimed?
  56. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57. Of course, going through the steps of claiming tickets is overkill in some
  58. cases. In the case of small changes, such as typos in the documentation or
  59. small bugs that will only take a few minutes to fix, you don't need to jump
  60. through the hoops of claiming tickets. Just submit your patch and be done with
  61. it. Of course, it is always acceptable, regardless of the ticket's ownership
  62. status, to submit patches to a ticket if you happen to have a patch ready.
  63. .. _patch-style:
  64. Patch style
  65. -----------
  66. Make sure that any contribution you do fulfills at least the following
  67. requirements:
  68. * The code required to fix a problem or add a feature is an essential part
  69. of a patch, but it is not the only part. A good patch should also
  70. include a regression test to validate the behavior that has been fixed
  71. and to prevent the problem from arising again. Also, if some tickets are
  72. relevant to the code that you've written, mention the ticket numbers in
  73. some comments in the test so that one can easily trace back the relevant
  74. discussions after your patch gets committed and the tickets get closed.
  75. * If the code associated with a patch adds a new feature, or modifies
  76. behavior of an existing feature, the patch should also contain
  77. documentation.
  78. You can use either GitHub branches and pull requests or direct patches
  79. to publish your work. If you use the Git workflow, then you should
  80. announce your branch in the ticket by including a link to your branch.
  81. When you think your work is ready to be merged in create a pull request.
  82. See the :doc:`working-with-git` documentation for mode details.
  83. You can also use patches in Trac. When using this style, follow these
  84. guidelines.
  85. * Submit patches in the format returned by the ``git diff`` command.
  86. An exception is for code changes that are described more clearly in
  87. plain English than in code. Indentation is the most common example; it's
  88. hard to read patches when the only difference in code is that it's
  89. indented.
  90. * Attach patches to a ticket in the `ticket tracker`_, using the "attach
  91. file" button. Please *don't* put the patch in the ticket description
  92. or comment unless it's a single line patch.
  93. * Name the patch file with a ``.diff`` extension; this will let the ticket
  94. tracker apply correct syntax highlighting, which is quite helpful.
  95. Regardless of the way you submit your work, follow these steps.
  96. * Make sure your code matches our :doc:`coding-style`.
  97. * Check the "Has patch" box on the ticket details. This will make it
  98. obvious that the ticket includes a patch, and it will add the ticket to
  99. the `list of tickets with patches`_.
  100. Non-trivial patches
  101. -------------------
  102. A "non-trivial" patch is one that is more than a simple bug fix. It's a patch
  103. that introduces Django functionality and makes some sort of design decision.
  104. If you provide a non-trivial patch, include evidence that alternatives have
  105. been discussed on `django-developers`_. If you're not sure whether your patch
  106. should be considered non-trivial, just ask.
  107. Javascript patches
  108. ------------------
  109. Django's admin system leverages the jQuery framework to increase the
  110. capabilities of the admin interface. In conjunction, there is an emphasis on
  111. admin javascript performance and minimizing overall admin media file size.
  112. Serving compressed or "minified" versions of javascript files is considered
  113. best practice in this regard.
  114. To that end, patches for javascript files should include both the original
  115. code for future development (e.g. ``foo.js``), and a compressed version for
  116. production use (e.g. ``foo.min.js``). Any links to the file in the codebase
  117. should point to the compressed version.
  118. To simplify the process of providing optimized javascript code, Django
  119. includes a handy script which should be used to create a "minified" version.
  120. This script is located at ``django/contrib/admin/static/js/compress.py``.
  121. Behind the scenes, ``compress.py`` is a front-end for Google's
  122. `Closure Compiler`_ which is written in Java. However, the Closure Compiler
  123. library is not bundled with Django directly, so those wishing to contribute
  124. complete javascript patches will need to download and install the library
  125. independently.
  126. The Closure Compiler library requires Java version 6 or higher (Java 1.6 or
  127. higher on Mac OS X). Note that Mac OS X 10.5 and earlier did not ship with
  128. Java 1.6 by default, so it may be necessary to upgrade your Java installation
  129. before the tool will be functional. Also note that even after upgrading Java,
  130. the default ``/usr/bin/java`` command may remain linked to the previous Java
  131. binary, so relinking that command may be necessary as well.
  132. Please don't forget to run ``compress.py`` and include the ``diff`` of the
  133. minified scripts when submitting patches for Django's javascript.
  134. .. _Closure Compiler: https://developers.google.com/closure/compiler/
  135. .. _django-developers: http://groups.google.com/group/django-developers
  136. .. _list of tickets with patches: https://code.djangoproject.com/query?status=new&status=assigned&status=reopened&has_patch=1&order=priority
  137. .. _ticket tracker: https://code.djangoproject.com/newticket