Fixed #18436 -- Updated contributing docs for git.

Most of the credit for this large patch goes to Anssi Kääriäinen.
Many thanks to all the people who contributed to the discussion.
This commit is contained in:
Aymeric Augustin 2012-06-07 18:48:29 +02:00
parent 1a412dda62
commit 90fb6a4648
12 changed files with 626 additions and 483 deletions

View File

@ -204,7 +204,7 @@ The Django open-source project
:doc:`How to get involved <internals/contributing/index>` |
:doc:`The release process <internals/release-process>` |
:doc:`Team of committers <internals/committers>` |
:doc:`The Django source code repository <internals/svn>`
:doc:`The Django source code repository <internals/git>`
* **Design philosophies:**
:doc:`Overview <misc/design-philosophies>`

View File

@ -149,9 +149,8 @@ description.
As with most open-source projects, code talks. If you are willing to write the
code for the feature yourself or, even better, if you've already written it,
it's much more likely to be accepted. If it's a large feature that might need
multiple developers, we're always happy to give you an experimental branch in
our repository; see the :doc:`writing-code/branch-policy`.
it's much more likely to be accepted. Just fork Django on GitHub, create a
feature branch, and show us your work!
See also: :ref:`documenting-new-features`.

View File

@ -32,11 +32,91 @@ Decisions on new committers will follow the process explained in
existing committer privately. Public requests for commit access are potential
flame-war starters, and will be ignored.
Handling pull requests
----------------------
Since Django is now hosted at GitHub, many patches are provided in the form of
pull requests. When committing a pull request, make sure each individual
commit matches the commit guidelines described below. Contributors are
expected to provide the best pull requests possible. However, in practice,
committers are more familiar with the commit guidelines, and they may have to
rewrite the commit history.
Here is one way to commit a pull request::
# Create a new branch tracking upstream/master -- upstream is assumed
# to be django/django.
git checkout -b pull_xxxx upstream/master
# Download the patches from github and apply them.
curl https://github.com/django/django/pull/XXXX.patch | git am
At this point, you can work on the code. Use ``git rebase -i`` and ``git
commit --amend`` to make sure the commits have the expected level of quality.
Once you're ready::
# Make sure master is ready to receive changes.
git checkout master
git pull upstream master
# Merge the work as "fast-forward" to master, to avoid a merge commit.
git merge --ff-only pull_xx
# Check that only the changes you expect will be pushed to upstream.
git push --dry-run upstream master
# Push!
git push upstream master
# Get rid of the pull_xxxx branch.
git branch -d pull_xxxx
An alternative is to add the contributor's repository as a new remote, do a
checkout of the branch and work from there::
git remote add <contributor> https://github.com/<contributor>/django.git
git checkout pull_xxxx <contributor> <contributor's pull request branch>
At this point, you can work on the code and continue as above.
GitHub provides a one-click merge functionality for pull requests. This should
only be used if the pull request is 100% ready, and you have checked it for
errors (or trust the request maker enough to skip checks). Currently, it isn't
possible to control that the tests pass and that the docs build without
downloading the changes to your developement environment.
When rewriting the commit history of a pull request, the goal is to make
Django's commit history is as usable as possible:
* If a patch contains back-and-forth commits, then rewrite those into one.
Typically, a commit can add some code, and a second commit can fix
stylistic issues introduced in the first commit.
* Separate changes to different commits by logical grouping: if you do a
stylistic cleanup at the same time you do other changes to a file,
separating the changes to two different commits will make reviewing
history easier.
* Beware of merges of upstream branches in the pull requests.
* Tests should pass and docs should build after each commit. Neither the
tests nor the docs should emit warnings.
* Trivial and small patches usually are best done in one commit. Medium to
large work should be split in multiple commits if possible.
Practicality beats purity, so it is up to each committer to decide how much
history mangling to do for a pull request. The main points are engaging the
community, getting work done, and having an usable commit history.
.. _committing-guidlines:
Committing guidelines
---------------------
Please follow these guidelines when committing code to Django's Subversion
repository:
In addition, please follow the following guidelines when committing code to
Django's Git repository:
* Never change the published history of django/django branches! **Never force-
push your changes to django/django.** If you absolutely must (for security
reasons for example) first discuss the situation with the core team.
* For any medium-to-big changes, where "medium-to-big" is according to
your judgment, please bring things up on the `django-developers`_
@ -55,8 +135,23 @@ repository:
* Bad: "Fixes Unicode bug in RSS API."
* Bad: "Fixing Unicode bug in RSS API."
The commit message should be in lines of 72 chars maximum. There should be
a subject line, separated by a blank line and then paragraphs of 72 char
lines. The limits are soft. For the subject line, shorter is better. In the
body of the commit message more detail is better than less::
Fixed #18307 -- Added git workflow guidelines
Refactored the Django's documentation to remove mentions of SVN
specific tasks. Added guidelines of how to use Git, GitHub, and
how to use pull request together with Trac instead.
If the patch wasn't a pull request, you should credit the contributors in
the commit message: "Thanks A for report, B for the patch and C for the
review."
* For commits to a branch, prefix the commit message with the branch name.
For example: "magic-removal: Added support for mind reading."
For example: "[1.4.x] Fixed #NNNNN -- Added support for mind reading."
* Limit commits to the most granular change that makes sense. This means,
use frequent small commits rather than infrequent large commits. For
@ -65,31 +160,29 @@ repository:
separate commit. This goes a *long way* in helping all core Django
developers follow your changes.
* Separate bug fixes from feature changes.
Bug fixes need to be added to the current bugfix branch as well as the
current trunk.
* Separate bug fixes from feature changes. Bugfixes may need to be backported
to the stable branch, according to the :ref:`backwards-compatibility policy
<backwards-compatibility-policy>`.
* If your commit closes a ticket in the Django `ticket tracker`_, begin
your commit message with the text "Fixed #abc", where "abc" is the
your commit message with the text "Fixed #NNNNN", where "NNNNN" is the
number of the ticket your commit fixes. Example: "Fixed #123 -- Added
support for foo". We've rigged Subversion and Trac so that any commit
message in that format will automatically close the referenced ticket
and post a comment to it with the full commit message.
whizbang feature.". We've rigged Trac so that any commit message in that
format will automatically close the referenced ticket and post a comment
to it with the full commit message.
If your commit closes a ticket and is in a branch, use the branch name
first, then the "Fixed #abc." For example:
"magic-removal: Fixed #123 -- Added whizbang feature."
first, then the "Fixed #NNNNN." For example:
"[1.4.x] Fixed #123 -- Added whizbang feature."
For the curious: we're using a `Trac post-commit hook`_ for this.
For the curious, we're using a `Trac plugin`_ for this.
.. _Trac post-commit hook: http://trac.edgewall.org/browser/trunk/contrib/trac-svn-post-commit-hook.cmd
.. _Trac plugin: https://github.com/aaugustin/trac-github
* If your commit references a ticket in the Django `ticket tracker`_ but
does *not* close the ticket, include the phrase "Refs #abc", where "abc"
is the number of the ticket your commit references. We've rigged
Subversion and Trac so that any commit message in that format will
automatically post a comment to the appropriate ticket.
does *not* close the ticket, include the phrase "Refs #NNNNN", where "NNNNN"
is the number of the ticket your commit references. This will automatically
post a comment to the appropriate ticket.
* Write commit messages for backports using this pattern::
@ -99,9 +192,9 @@ repository:
For example::
[1.3.X] Fixed #17028 - Changed diveintopython.org -> diveintopython.net.
[1.3.x] Fixed #17028 - Changed diveintopython.org -> diveintopython.net.
Backport of r17115 from trunk.
Backport of 80c0cbf1c97047daed2c5b41b296bbc56fe1d7e3 from trunk.
Reverting commits
-----------------
@ -111,14 +204,17 @@ discovered, please follow these guidelines:
* Try very hard to ensure that mistakes don't happen. Just because we
have a reversion policy doesn't relax your responsibility to aim for
the highest quality possible. Really: double-check your work before
you commit it in the first place!
the highest quality possible. Really: double-check your work, or have
it checked by another committer, before you commit it in the first place!
* If possible, have the original author revert his/her own commit.
* Don't revert another author's changes without permission from the
original author.
* Use git revert -- this will make a reverse commit, but the original
commit will still be part of the commit history.
* If the original author can't be reached (within a reasonable amount
of time -- a day or so) and the problem is severe -- crashing bug,
major test failures, etc -- then ask for objections on the
@ -139,5 +235,9 @@ discovered, please follow these guidelines:
* The release branch maintainer may back out commits to the release
branch without permission if the commit breaks the release branch.
* If you mistakenly push a topic branch to django/django, just delete it.
For instance, if you did: ``git push upstream feature_antigravity``,
just do a reverse push: ``git push upstream :feature_antigravity``.
.. _django-developers: http://groups.google.com/group/django-developers
.. _ticket tracker: https://code.djangoproject.com/newticket

View File

@ -1,171 +0,0 @@
=============
Branch policy
=============
In general, the trunk must be kept stable. People should be able to run
production sites against the trunk at any time. Additionally, commits to trunk
ought to be as atomic as possible -- smaller changes are better. Thus, large
feature changes -- that is, changes too large to be encapsulated in a single
patch, or changes that need multiple eyes on them -- must happen on dedicated
branches.
This means that if you want to work on a large feature -- anything that would
take more than a single patch, or requires large-scale refactoring -- you need
to do it on a feature branch. Our development process recognizes two options
for feature branches:
1. Feature branches using a distributed revision control system like
Git_, Mercurial_, Bazaar_, etc.
If you're familiar with one of these tools, this is probably your best
option since it doesn't require any support or buy-in from the Django
core developers.
However, do keep in mind that Django will continue to use Subversion
for the foreseeable future, and this will naturally limit the
recognition of your branch. Further, if your branch becomes eligible
for merging to trunk you'll need to find a core developer familiar
with your DVCS of choice who'll actually perform the merge.
If you do decided to start a distributed branch of Django and choose to
make it public, please add the branch to the `Django branches`_ wiki
page.
2. Feature branches using SVN have a higher bar. If you want a branch
in SVN itself, you'll need a "mentor" among the :doc:`core committers
</internals/committers>`. This person is responsible for actually
creating the branch, monitoring your process (see below), and
ultimately merging the branch into trunk.
If you want a feature branch in SVN, you'll need to ask in
`django-developers`_ for a mentor.
.. _git: http://git-scm.com/
.. _mercurial: http://mercurial.selenic.com/
.. _bazaar: http://bazaar.canonical.com/
.. _django branches: https://code.djangoproject.com/wiki/DjangoBranches
Branch rules
------------
We've got a few rules for branches born out of experience with what makes a
successful Django branch.
DVCS branches are obviously not under central control, so we have no way of
enforcing these rules. However, if you're using a DVCS, following these rules
will give you the best chance of having a successful branch (read: merged back
to trunk).
Developers with branches in SVN, however, **must** follow these rules. The
branch mentor will keep on eye on the branch and **will delete it** if these
rules are broken.
* Only branch entire copies of the Django tree, even if work is only
happening on part of that tree. This makes it painless to switch to a
branch.
* Merge changes from trunk no less than once a week, and preferably every
couple-three days.
In our experience, doing regular trunk merges is often the difference
between a successful branch and one that fizzles and dies.
If you're working on an SVN branch, you should be using `svnmerge.py`_
to track merges from trunk.
* Keep tests passing and documentation up-to-date. As with patches,
we'll only merge a branch that comes with tests and documentation.
.. _svnmerge.py: http://www.orcaware.com/svn/wiki/Svnmerge.py
Once the branch is stable and ready to be merged into the trunk, alert
`django-developers`_.
After a branch has been merged, it should be considered "dead"; write access
to it will be disabled, and old branches will be periodically "trimmed."
To keep our SVN wrangling to a minimum, we won't be merging from a given
branch into the trunk more than once.
Using branches
--------------
To use a branch, you'll need to do two things:
* Get the branch's code through Subversion.
* Point your Python ``site-packages`` directory at the branch's version of
the ``django`` package rather than the version you already have
installed.
Getting the code from Subversion
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the latest version of a branch's code, check it out using Subversion:
.. code-block:: bash
svn co https://code.djangoproject.com/svn/django/branches/<branch>/
...where ``<branch>`` is the branch's name. See the `list of branch names`_.
Alternatively, you can automatically convert an existing directory of the
Django source code as long as you've checked it out via Subversion. To do the
conversion, execute this command from within your ``django`` directory:
.. code-block:: bash
svn switch https://code.djangoproject.com/svn/django/branches/<branch>/
The advantage of using ``svn switch`` instead of ``svn co`` is that the
``switch`` command retains any changes you might have made to your local copy
of the code. It attempts to merge those changes into the "switched" code. The
disadvantage is that it may cause conflicts with your local changes if the
"switched" code has altered the same lines of code.
(Note that if you use ``svn switch``, you don't need to point Python at the
new version, as explained in the next section.)
.. _list of branch names: https://code.djangoproject.com/browser/django/branches
.. _pointing-python-at-the-new-django-version:
Pointing Python at the new Django version
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Once you've retrieved the branch's code, you'll need to change your Python
``site-packages`` directory so that it points to the branch version of the
``django`` directory. (The ``site-packages`` directory is somewhere such as
``/usr/lib/python2.7/site-packages`` or
``/usr/local/lib/python2.7/site-packages`` or ``C:\Python\site-packages``.)
The simplest way to do this is by renaming the old ``django`` directory to
``django.OLD`` and moving the trunk version of the code into the directory
and calling it ``django``.
Alternatively, you can use a symlink called ``django`` that points to the
location of the branch's ``django`` package. If you want to switch back, just
change the symlink to point to the old code.
A third option is to use a path file (``<something>.pth``). This is a feature of
the :mod:`site` module. First, make sure there are no files, directories or
symlinks named ``django`` in your ``site-packages`` directory. Then create a
text file named ``django.pth`` and save it to your ``site-packages`` directory.
That file should contain a path to your copy of Django on a single line and
optional comments. Here is an example that points to multiple branches. Just
uncomment the line for the branch you want to use ('trunk' in this example) and
make sure all other lines are commented::
# Trunk is a svn checkout of:
# https://code.djangoproject.com/svn/django/trunk/
#
/path/to/trunk
# <branch> is a svn checkout of:
# https://code.djangoproject.com/svn/django/branches/<branch>/
#
#/path/to/<branch>
# On windows a path may look like this:
# C:/path/to/<branch>
.. _django-developers: http://groups.google.com/group/django-developers

View File

@ -12,4 +12,4 @@ chances to be included in Django core:
coding-style
unit-tests
submitting-patches
branch-policy
working-with-git

View File

@ -6,6 +6,15 @@ We're always grateful for patches to Django's code. Indeed, bug reports
with associated patches will get fixed *far* more quickly than those
without patches.
Typo fixes and trivial documentation changes
--------------------------------------------
If you are fixing a really trivial issue, for example changing a word in the
documentation, the preferred way to provide the patch is using GitHub pull
requests without a Trac ticket. Trac tickets are still acceptable.
See the :doc:`working-with-git` for more details on how to use pull requests.
"Claiming" tickets
------------------
@ -69,38 +78,16 @@ Of course, going through the steps of claiming tickets is overkill in some
cases. In the case of small changes, such as typos in the documentation or
small bugs that will only take a few minutes to fix, you don't need to jump
through the hoops of claiming tickets. Just submit your patch and be done with
it.
it. Of course, it is always acceptable, regardless of the ticket's ownership
status, to submit patches to a ticket if you happen to have a patch ready.
.. _patch-style:
Patch style
-----------
* Make sure your code matches our :doc:`coding-style`.
* Submit patches in the format returned by the ``svn diff`` command.
An exception is for code changes that are described more clearly in
plain English than in code. Indentation is the most common example; it's
hard to read patches when the only difference in code is that it's
indented.
Patches in ``git diff`` format are also acceptable.
* When creating patches, always run ``svn diff`` from the top-level
``trunk`` directory -- i.e. the one that contains ``django``, ``docs``,
``tests``, ``AUTHORS``, etc. This makes it easy for other people to
apply your patches.
* Attach patches to a ticket in the `ticket tracker`_, using the "attach
file" button. Please *don't* put the patch in the ticket description
or comment unless it's a single line patch.
* Name the patch file with a ``.diff`` extension; this will let the ticket
tracker apply correct syntax highlighting, which is quite helpful.
* Check the "Has patch" box on the ticket details. This will make it
obvious that the ticket includes a patch, and it will add the ticket to
the `list of tickets with patches`_.
Make sure that any contribution you do fulfills at least the following
requirements:
* The code required to fix a problem or add a feature is an essential part
of a patch, but it is not the only part. A good patch should also
@ -114,6 +101,37 @@ Patch style
behavior of an existing feature, the patch should also contain
documentation.
You can use either GitHub branches and pull requests or direct patches
to publish your work. If you use the Git workflow, then you should
announce your branch in the ticket by including a link to your branch.
When you think your work is ready to be merged in create a pull request.
See the :doc:`working-with-git` documentation for mode details.
You can also use patches in Trac. When using this style, follow these
guidelines.
* Submit patches in the format returned by the ``git diff`` command.
An exception is for code changes that are described more clearly in
plain English than in code. Indentation is the most common example; it's
hard to read patches when the only difference in code is that it's
indented.
* Attach patches to a ticket in the `ticket tracker`_, using the "attach
file" button. Please *don't* put the patch in the ticket description
or comment unless it's a single line patch.
* Name the patch file with a ``.diff`` extension; this will let the ticket
tracker apply correct syntax highlighting, which is quite helpful.
Regardless of the way you submit your work, follow these steps.
* Make sure your code matches our :doc:`coding-style`.
* Check the "Has patch" box on the ticket details. This will make it
obvious that the ticket includes a patch, and it will add the ticket to
the `list of tickets with patches`_.
Non-trivial patches
-------------------

View File

@ -36,9 +36,7 @@ with this sample ``settings`` module, ``cd`` into the Django
./runtests.py --settings=test_sqlite
If you get an ``ImportError: No module named django.contrib`` error,
you need to add your install of Django to your ``PYTHONPATH``. For
more details on how to do this, read
:ref:`pointing-python-at-the-new-django-version`.
you need to add your install of Django to your ``PYTHONPATH``.
Using another ``settings`` module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -0,0 +1,222 @@
Working with Git and GitHub
===========================
Django uses `Git`_ for its source control. You can `download
<http://git-scm.com/download>`_ Git, but it's often easier to install with
your operating system's package manager.
Django's `Git repository`_ is hosted on `GitHub`_, and it is recommended
that you also work using GitHub.
After installing Git the first thing you should do is setup your name and
email::
$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "your_email@youremail.com"
Note that ``user.name`` should be your real name, not your GitHub nick. GitHub
should know the email you use in the ``user.email`` field, as this will be
used to associate your commits with your GitHub account.
Now we are going to show how to create a GitHub pull request containing the
changes for Trac ticket #xxxxx. By creating a fully ready pull request you
will make the committers' job easier, and thus your work is more likely to be
merged into Django. You can also upload a traditional patch to Trac, but it's
less practical for reviews.
.. _Git: http://git-scm.com/
.. _GitHub: https://github.com/
.. _Git repository: https://github.com/django/django/
Setting up local repository
---------------------------
When you have created a GitHub account, with the nick "github_nick", and
forked Django's repository, you should create a local copy of your fork::
git clone git@github.com:github_nick/django.git
This will create a new directory "django" containing a clone of your GitHub
repository. Your GitHub repository will be called "origin" in Git. You should
also setup django/django as an "upstream" remote::
git remote add upstream git@github.com:django/django.git
git fetch upstream
You can add other remotes similarly, for example::
git remote add akaariai git@github.com:akaariai/django.git
Working on a ticket
-------------------
When working on a ticket you will almost always want to create a new branch
for the work, and base that work on upstream/master::
git checkout -b ticket_xxxxx upstream/master
If you are working for a fix on the 1.4 branch, you would instead do::
git checkout -b ticket_xxxxx_1_4 upstream/stable/1.4.x
Assume the work is carried on ticket_xxxxx branch. Make some changes and
commit them::
git commit
When writing the commit message, you should follow the :ref:`commit message
guidelines <committing-guidlines>` to ease the work of the committer. If
you're uncomfortable with English, try at least to describe precisely what the
commit does.
If you need to do additional work on your branch, commit as often as
necessary::
git commit -m 'Added two more tests for edge cases'
Publishing work
~~~~~~~~~~~~~~~
You can publish your work on GitHub by just using::
git push origin ticket_xxxxx
When you go to your GitHub page you will notice a new branch has been created.
If you are working on a Trac ticket, you should mention in the ticket that
your work is available from branch ticket_xxxxx of your github repo. Include a
link to your branch.
Note that the above branch is called a "topic branch" in Git parlance. This
means that other people should not base their work on your branch. In
particular this means you are free to rewrite the history of this branch (by
using ``git rebase`` for example). There are also "public branches". These are
branches other people are supposed to fork, and thus their history should
never change. Good examples of public branches are the ``master`` and
``stable/A.B.x`` branches in the django/django repository.
When you think your work is ready to be pulled into Django, you should create
a pull request at GitHub. A good pull request contains:
* Commits with one logical change in each, following the
:doc:`coding style <coding-style>`.
* Well formed messages for each commit: a summary line and then paragraphs
wrapped at 72 characters thereafter. See the :ref:`committing guidelines
<committing-guidlines>` for more details.
* Documentation and tests, if needed. Actually tests are always needed, except
for documentation changes.
* The test suite passes and the documentation builds without warnings.
Once you have created your pull request, you should add a comment in the
related Trac ticket explaining what you've done. In particular you should tell
in which environment you've run the tests, for instance: "all tests pass under
SQLite and MySQL".
Your pull request should be ready for merging into Django. Pull requests at
GitHub have only two states: open and closed. The committers who deals with
your pull request has only two options: merge it or close it. For this reason,
it isn't useful to make a pull request until the code is ready for merging --
or sufficiently close that a committer will finish it himself.
Rebasing branches
~~~~~~~~~~~~~~~~~
In the example above you created two commits, the "Fixed ticket_xxxxx" commit
and "Added two more tests" commit. We do not want to have the "Added two more
tests" commit in the Django's repository as it would just be useless noise.
Instead, we would like to only have one commit. To rework the history of your
branch you can squash the commits into one by using interactive rebase::
git rebase -i HEAD~2
The HEAD~2 above is shorthand for two latest commits. The above command
will open an editor showing the two commits, prefixed with the word "pick".
You should change the second line to "squash" instead. This will keep the
first commit, and squash the second commit to the first one. Save and quit
the editor. A second editor window should open. Here you can reword the
commit message for the commit.
You can also use the "edit" option in rebase. This way you can change a single
commit. For example::
git rebase -i HEAD~3
# Choose edit, pick, pick for the commits
# Now you are able to rework the commit (use git add normally to add changes)
# When finished, commit work with "--amend" and continue
git commit --amend
# reword the commit message if needed
git rebase --continue
# The second and third commit should be applied.
If you need to change an already published topic branch at GitHub, you will
need to force-push the changes::
git push -f origin ticket_xxxxx
Note that this will rewrite history of ticket_xxxxx - if you check the commit
hashes before and after the operation at GitHub you will notice that the
commit hashes do not match any more. This is acceptable, as the branch is topic
branch, and nobody should be basing their work on this branch.
After upstream has changed
~~~~~~~~~~~~~~~~~~~~~~~~~~
When upstream (django/django) has changed, you should rebase your work. To
do this, use::
git fetch upstream
git rebase
The work is automatically rebased using the branch you forked on, in the
example case using upstream/master.
The rebase command removes all your local commits temporarily, applies the
upstream commits, and then applies your local commits again on the work. If
there are merge conflicts you will need to resolve them and then use ``git
rebase --continue``. At any point you can use ``git rebase --abort`` to return
to the original state.
Note that you want to rebase on upstream, not merge the upstream. The reason
for this is that by rebasing, your commits will always be on top of the
upstream's work, not mixed with the changes in the upstream. This way your
branch only contains commits related to its topic, and this makes squashing
easier.
After review
------------
It is unusual to get any non-trivial amount of code into core without changes
requested by reviewers. In this case, it is often a good idea to add the
changes as one incremental commit to your work. This allows the reviewer to
easily check what changes you have done::
# Do changes required by the reviewer, commit often.
# Before publishing the changes, rebase your work. Assume you added two
# commits to the work.
git rebase -i HEAD~2
# squash the second commit into the first, write a commit message something
# like this:
Made changes asked in review by the_reviewer
- Fixed whitespace errors in foo/bar
- Reworded the doc string of the_method()
# Push your work back to your github repo, there should not be any need
# for force (-f) push, as you didn't touch the public commits in the rebase.
git push origin ticket_xxxxx
# Check your pull request, it should now contain the new commit, too.
The committer is likely to squash the review commit into the previous commit
when committing the code.
Summary
-------
* Work on GitHub if possible.
* Announce your work on the Trac ticket by linking to your GitHub branch.
* When you have something ready, make a pull request.
* Make your pull requests as good as you can.
* When doing fixes to your work, use ``git rebase -i`` to squash the commits.
* When upstream has changed, do ``git fetch upstream; git rebase``.

229
docs/internals/git.txt Normal file
View File

@ -0,0 +1,229 @@
=================================
The Django source code repository
=================================
When deploying a Django application into a real production environment, you
will almost always want to use `an official packaged release of Django`_.
However, if you'd like to try out in-development code from an upcoming release
or contribute to the development of Django, you'll need to obtain a clone of
Django's source code repository. This document covers the way the code
repository is laid out and how to work with and find things in it.
.. _an official packaged release of Django: https://www.djangoproject.com/download/
High-level overview
===================
The Django source code repository uses `Git`_ to track changes to the code
over time, so you'll need a copy of the Git client (a program called ``git``)
on your computer, and you'll want to familiarize yourself with the basics of
how Git works. Git's web site offers downloads for various operating systems.
The site contains also vast amounts of `documentation`_.
The Django Git repository is located online at `github.com/django/django
<https://github.com/django/django>`_. It contains the full source
code for all Django releases, and you can browse it online.
The Git repository includes several `branches`_:
* ``master`` contains the main in-development code which will become
the next packaged release of Django. This is where most development
activity is focused.
* ``stable/A.B.x`` are the maintenance branches. They are used to support
older versions of Django.
* ``soc20XX/<project>`` branches were used by students who worked on Django
during the 2009 and 2010 Google Summer of Code programs.
* ``attic/<project>`` branches were used to develop major or experimental new
features without affecting the rest of Django's code.
The Git repository also contains `tags`_. They identify snapshots of Django's
code at various important points in its history. Mostly these are the exact
revisions from which packaged Django releases were produced.
The source code for `Djangoproject.com <https://www.djangoproject.com/>`_ Web
site can be found at `github.com/django/djangoproject.com
<https://github.com/django/djangoproject.com>`_.
.. _Git: http://git-scm.com/
.. _documentation: http://git-scm.com/documentation
.. _branches: https://github.com/django/django/branches
.. _tags: https://github.com/django/django/tags
Working with Django's master branch
===================================
If you'd like to try out the in-development code for the next release of
Django, or if you'd like to contribute to Django by fixing bugs or developing
new features, you'll want to get the code from the master branch.
Note that this will get *all* of Django: in addition to the top-level
``django`` module containing Python code, you'll also get a copy of Django's
documentation, test suite, packaging scripts and other miscellaneous bits.
Django's code will be present in your clone as a directory named
``django``.
To try out the in-development code with your own applications, simply place
the directory containing your clone on your Python import path. Then
``import`` statements which look for Django will find the ``django`` module
within your clone.
If you're going to be working on Django's code (say, to fix a bug or
develop a new feature), you can probably stop reading here and move
over to :doc:`the documentation for contributing to Django
</internals/contributing/index>`, which covers things like the preferred
coding style and how to generate and submit a patch.
Branches
========
Django uses branches for two main purposes:
1. Development of major or experimental features, to keep them from
affecting progress on other work in master.
2. Security and bug-fix support for older releases of Django, during
their support lifetimes.
Feature-development branches
----------------------------
.. admonition:: Historical information
Since Django moved to Git in 2012, anyone can clone the repository and
create his own branches, alleviating the need for official branches in the
source code repository.
The following section is mostly useful if you're exploring the repository's
history, for example if you're trying to understand how some features were
designed.
Feature-development branches tend by their nature to be temporary. Some
produce successful features which are merged back into Django's master to
become part of an official release, but others do not; in either case there
comes a time when the branch is no longer being actively worked on by any
developer. At this point the branch is considered closed.
Unfortunately, Django used to be maintained with the Subversion revision
control system, that has no standard way of indicating this. As a workaround,
branches of Django which are closed and no longer maintained were moved into
``attic``.
For reference, the following are branches whose code eventually became
part of Django itself, and so are no longer separately maintained:
* ``boulder-oracle-sprint``: Added support for Oracle databases to
Django's object-relational mapper. This has been part of Django
since the 1.0 release.
* ``gis``: Added support for geographic/spatial queries to Django's
object-relational mapper. This has been part of Django since the 1.0
release, as the bundled application ``django.contrib.gis``.
* ``i18n``: Added :doc:`internationalization support </topics/i18n/index>` to
Django. This has been part of Django since the 0.90 release.
* ``magic-removal``: A major refactoring of both the internals and
public APIs of Django's object-relational mapper. This has been part
of Django since the 0.95 release.
* ``multi-auth``: A refactoring of :doc:`Django's bundled
authentication framework </topics/auth>` which added support for
:ref:`authentication backends <authentication-backends>`. This has
been part of Django since the 0.95 release.
* ``new-admin``: A refactoring of :doc:`Django's bundled
administrative application </ref/contrib/admin/index>`. This became part of
Django as of the 0.91 release, but was superseded by another
refactoring (see next listing) prior to the Django 1.0 release.
* ``newforms-admin``: The second refactoring of Django's bundled
administrative application. This became part of Django as of the 1.0
release, and is the basis of the current incarnation of
``django.contrib.admin``.
* ``queryset-refactor``: A refactoring of the internals of Django's
object-relational mapper. This became part of Django as of the 1.0
release.
* ``unicode``: A refactoring of Django's internals to consistently use
Unicode-based strings in most places within Django and Django
applications. This became part of Django as of the 1.0 release.
When Django moved from SVN to Git, the information about branch merges wasn't
preserved in the source code repository. This means that the ``master`` branch
of Django doesn't contain merge commits for the above branches. However, this
information is `available as a grafts file`_. You can restore it by putting
the following lines in ``.git/info/grafts`` in your local clone::
ac64e91a0cadc57f4bc5cd5d66955832320ca7a1 553a20075e6991e7a60baee51ea68c8adc520d9a 0cb8e31823b2e9f05c4ae868c19f5f38e78a5f2e
79e68c225b926302ebb29c808dda8afa49856f5c d0f57e7c7385a112cb9e19d314352fc5ed5b0747 aa239e3e5405933af6a29dac3cf587b59a099927
5cf8f684237ab5addaf3549b2347c3adf107c0a7 cb45fd0ae20597306cd1f877efc99d9bd7cbee98 e27211a0deae2f1d402537f0ebb64ad4ccf6a4da
f69cf70ed813a8cd7e1f963a14ae39103e8d5265 d5dbeaa9be359a4c794885c2e9f1b5a7e5e51fb8 d2fcbcf9d76d5bb8a661ee73dae976c74183098b
aab3a418ac9293bb4abd7670f65d930cb0426d58 4ea7a11659b8a0ab07b0d2e847975f7324664f10 adf4b9311d5d64a2bdd58da50271c121ea22e397
ff60c5f9de3e8690d1e86f3e9e3f7248a15397c8 7ef212af149540aa2da577a960d0d87029fd1514 45b4288bb66a3cda401b45901e85b645674c3988
9dda4abee1225db7a7b195b84c915fdd141a7260 4fe5c9b7ee09dc25921918a6dbb7605edb374bc9 3a7c14b583621272d4ef53061287b619ce3c290d
a19ed8aea395e8e07164ff7d85bd7dff2f24edca dc375fb0f3b7fbae740e8cfcd791b8bccb8a4e66 42ea7a5ce8aece67d16c6610a49560c1493d4653
9c52d56f6f8a9cdafb231adf9f4110473099c9b5 c91a30f00fd182faf8ca5c03cd7dbcf8b735b458 4a5c5c78f2ecd4ed8859cd5ac773ff3a01bccf96
953badbea5a04159adbfa970f5805c0232b6a401 4c958b15b250866b70ded7d82aa532f1e57f96ae 5664a678b29ab04cad425c15b2792f4519f43928
471596fc1afcb9c6258d317c619eaf5fd394e797 4e89105d64bb9e04c409139a41e9c7aac263df4c 3e9035a9625c8a8a5e88361133e87ce455c4fc13
9233d0426537615e06b78d28010d17d5a66adf44 6632739e94c6c38b4c5a86cf5c80c48ae50ac49f 18e151bc3f8a85f2766d64262902a9fcad44d937
.. _available as a grafts file: https://github.com/ramiro/django-git-grafts
Additionally, the following branches are closed, but their code was
never merged into Django and the features they aimed to implement
were never finished:
* ``full-history``
* ``generic-auth``
* ``multiple-db-support``
* ``per-object-permissions``
* ``schema-evolution``
* ``schema-evolution-ng``
* ``search-api``
* ``sqlalchemy``
All of the above-mentioned branches now reside in ``attic``.
Finally, the repository contains ``soc2009/xxx`` and ``soc2010/xxx`` feature
branches, used for Google Summer of Code projects.
Support and bugfix branches
---------------------------
In addition to fixing bugs in current master, the Django project provides
official bug-fix support for the most recent released version of Django, and
security support for the two most recently-released versions of Django. This
support is provided via branches in which the necessary bug or security fixes
are applied; the branches are then used as the basis for issuing bugfix or
security releases.
These branches can be found in the repository as ``stable/A.B.x``
branches, and new branches will be created there after each new Django
release. For example, shortly after the release of Django 1.0, the branch
``stable/1.0.x`` was created to receive bug fixes, and shortly after the
release of Django 1.1 the branch ``stable/1.1.x`` was created.
Official support for the above mentioned releases has expired, and so they no
longer receive direct maintenance from the Django project. However, the
branches continue to exist and interested community members have occasionally
used them to provide unofficial support for old Django releases.
Tags
====
Each Django release is tagged and signed by Django's release manage.
The tags can be found on GitHub's `tags`_ page.
.. _tags: https://github.com/django/django/tags

View File

@ -20,4 +20,4 @@ the hood".
committers
release-process
deprecation
svn
git

View File

@ -84,6 +84,8 @@ person will be responsible for making sure that bug fixes are applied to both
trunk and the maintained micro-release branch. This person will also work with
the release manager to decide when to release the micro releases.
.. _backwards-compatibility-policy:
Supported versions
==================

View File

@ -1,254 +0,0 @@
=================================
The Django source code repository
=================================
When deploying a Django application into a real production
environment, you will almost always want to use `an official packaged
release of Django`_. However, if you'd like to try out in-development
code from an upcoming release or contribute to the development of
Django, you'll need to obtain a checkout from Django's source code
repository. This document covers the way the code repository is laid
out and how to work with and find things in it.
.. _an official packaged release of Django: https://www.djangoproject.com/download/
High-level overview
===================
The Django source code repository uses `Subversion`_ to track changes
to the code over time, so you'll need a copy of the Subversion client
(a program called ``svn``) on your computer, and you'll want to
familiarize yourself with the basics of how Subversion
works. Subversion's Web site offers downloads for various operating
systems, and `a free online book`_ is available to help you get up to
speed with using Subversion.
The Django Subversion repository is located online at
`code.djangoproject.com/svn <https://code.djangoproject.com/svn/>`_. `A
friendly Web-based interface for browsing the code`_ is also
available, though when using Subversion you'll always want to use the
repository address instead. At the top level of the repository are two
directories: ``django`` contains the full source code for all Django
releases, while ``djangoproject.com`` contains the source code and
templates for the `djangoproject.com <https://www.djangoproject.com/>`_
Web site. For trying out in-development Django code, or contributing
to Django, you'll always want to check out code from some location in
the ``django`` directory.
Inside the ``django`` directory, Django's source code is organized
into three areas:
* ``branches`` contains branched copies of Django's code, which are
(or were) maintained for various purposes. Some branches exist to
provide a place to develop major or experimental new features
without affecting the rest of Django's code, while others serve to
provide bug fixes or support for older Django releases.
* ``tags`` contains snapshots of Django's code at various important
points in its history; mostly these are the exact revisions from
which packaged Django releases were produced.
* ``trunk`` contains the main in-development code which will become
the next packaged release of Django, and is where most development
activity is focused.
.. _Subversion: http://subversion.tigris.org/
.. _a free online book: http://svnbook.red-bean.com/
.. _A friendly Web-based interface for browsing the code: https://code.djangoproject.com/browser/
Working with Django's trunk
===========================
If you'd like to try out the in-development code for the next release
of Django, or if you'd like to contribute to Django by fixing bugs or
developing new features, you'll want to get the code from trunk. You
can get a complete copy of this code (a "Subversion checkout") by
typing::
svn co https://code.djangoproject.com/svn/django/trunk/
Note that this will get *all* of Django: in addition to the top-level
``django`` module containing Python code, you'll also get a copy of
Django's documentation, unit-test suite, packaging scripts and other
miscellaneous bits. Django's code will be present in your checkout as
a directory named ``django``.
To try out the in-development trunk code with your own applications,
simply place the directory containing your checkout on your Python
import path. Then ``import`` statements which look for Django will find
the ``django`` module within your checkout.
If you're going to be working on Django's code (say, to fix a bug or
develop a new feature), you can probably stop reading here and move
over to :doc:`the documentation for contributing to Django
</internals/contributing/index>`, which covers things like the preferred
coding style and how to generate and submit a patch.
Branches
========
Django uses branches for two main purposes:
1. Development of major or experimental features, to keep them from
affecting progress on other work in trunk.
2. Security and bug-fix support for older releases of Django, during
their support lifetimes.
Feature-development branches
----------------------------
Feature-development branches tend by their nature to be
temporary. Some produce successful features which are merged back into
Django's trunk to become part of an official release, but others do
not; in either case there comes a time when the branch is no longer
being actively worked on by any developer. At this point the branch is
considered closed.
Unfortunately, Subversion has no standard way of indicating this. As a
workaround, branches of Django which are closed and no longer
maintained are moved into the directory ``django/branches/attic``.
For reference, the following are branches whose code eventually became
part of Django itself, and so are no longer separately maintained:
* ``boulder-oracle-sprint``: Added support for Oracle databases to
Django's object-relational mapper. This has been part of Django
since the 1.0 release.
* ``gis``: Added support for geographic/spatial queries to Django's
object-relational mapper. This has been part of Django since the 1.0
release, as the bundled application ``django.contrib.gis``.
* ``i18n``: Added :doc:`internationalization support </topics/i18n/index>` to
Django. This has been part of Django since the 0.90 release.
* ``magic-removal``: A major refactoring of both the internals and
public APIs of Django's object-relational mapper. This has been part
of Django since the 0.95 release.
* ``multi-auth``: A refactoring of :doc:`Django's bundled
authentication framework </topics/auth>` which added support for
:ref:`authentication backends <authentication-backends>`. This has
been part of Django since the 0.95 release.
* ``new-admin``: A refactoring of :doc:`Django's bundled
administrative application </ref/contrib/admin/index>`. This became part of
Django as of the 0.91 release, but was superseded by another
refactoring (see next listing) prior to the Django 1.0 release.
* ``newforms-admin``: The second refactoring of Django's bundled
administrative application. This became part of Django as of the 1.0
release, and is the basis of the current incarnation of
``django.contrib.admin``.
* ``queryset-refactor``: A refactoring of the internals of Django's
object-relational mapper. This became part of Django as of the 1.0
release.
* ``unicode``: A refactoring of Django's internals to consistently use
Unicode-based strings in most places within Django and Django
applications. This became part of Django as of the 1.0 release.
Additionally, the following branches are closed, but their code was
never merged into Django and the features they aimed to implement
were never finished:
* ``full-history``
* ``generic-auth``
* ``multiple-db-support``
* ``per-object-permissions``
* ``schema-evolution``
* ``schema-evolution-ng``
* ``search-api``
* ``sqlalchemy``
All of the above-mentioned branches now reside in
``django/branches/attic``.
Support and bugfix branches
---------------------------
In addition to fixing bugs in current trunk, the Django project
provides official bug-fix support for the most recent released version
of Django, and security support for the two most recently-released
versions of Django. This support is provided via branches in which the
necessary bug or security fixes are applied; the branches are then
used as the basis for issuing bugfix or security releases.
As of the Django 1.0 release, these branches can be found in the
repository in the directory ``django/branches/releases``, and new branches
will be created there approximately one month after each new Django
release. For example, shortly after the release of Django 1.0, the
branch ``django/branches/releases/1.0.X`` was created to receive bug
fixes, and shortly after the release of Django 1.1 the branch
``django/branches/releases/1.1.X`` was created.
Prior to the Django 1.0 release, these branches were maintained within
the top-level ``django/branches`` directory, and so the following
branches exist there and provided support for older Django releases:
* ``0.90-bugfixes``
* ``0.91-bugfixes``
* ``0.95-bugfixes``
* ``0.96-bugfixes``
Official support for those releases has expired, and so they no longer
receive direct maintenance from the Django project. However, the
branches continue to exist and interested community members have
occasionally used them to provide unofficial support for old Django
releases.
Tags
====
The directory ``django/tags`` within the repository contains complete
copies of the Django source code as it existed at various points in
its history. These "tagged" copies of Django are *never* changed or
updated; new tags may be added as needed, but once added they are
considered read-only and serve as useful guides to Django's
development history.
Within ``django/tags/releases`` are copies of the code which formed each
packaged release of Django, and each tag is named with the version
number of the release to which it corresponds. So, for example,
``django/tags/releases/1.1`` is a complete copy of the code which was
packaged as the Django 1.1 release.
Within ``django/tags/notable_moments`` are copies of the Django code from
points which do not directly correspond to releases, but which are
nonetheless important historical milestones for Django
development. The current "notable moments" marked there are:
* ``ipo``: Django's code as it existed at the moment Django was first
publicly announced in 2005.
* ``pre-magic-removal``: The state of Django's code just before the
merging of the ``magic-removal`` branch (described above), which
significantly updated Django's object-relational mapper.
* ``pre-newforms-admin``: The state of Django's code just before the
merging of the ``newforms-admin`` branch (see above), which
significantly updated Django's bundled administrative application.
* Tags corresponding to each of the alpha, beta and release-candidate
packages in the run up to the Django 1.0 release.