submitting-patches.txt 7.2 KB

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