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