Sophie

Sophie

distrib > Mageia > 6 > armv5tl > by-pkgid > 65530c6176058f9b54858c3b4f6385e6 > files > 639

python-django-doc-1.8.19-1.mga6.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" lang="">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Committing code &#8212; Django 1.8.19 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.8.19',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="top" title="Django 1.8.19 documentation" href="../../contents.html" />
    <link rel="up" title="Contributing to Django" href="index.html" />
    <link rel="next" title="Mailing lists" href="../mailing-lists.html" />
    <link rel="prev" title="Localizing Django" href="localizing.html" />



 
<script type="text/javascript" src="../../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head>
  <body role="document">

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../index.html">Django 1.8.19 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../index.html">Home</a>  |
        <a title="Table of contents" href="../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../genindex.html">Index</a>  |
        <a title="Module index" href="../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="localizing.html" title="Localizing Django">previous</a>
     |
    <a href="../index.html" title="Django internals" accesskey="U">up</a>
   |
    <a href="../mailing-lists.html" title="Mailing lists">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="internals-contributing-committing-code">
            
  <div class="section" id="s-committing-code">
<span id="committing-code"></span><h1>Committing code<a class="headerlink" href="#committing-code" title="Permalink to this headline">¶</a></h1>
<p>This section is addressed to the <a class="reference internal" href="../roles.html#committers"><span class="std std-ref">Committers</span></a> and to anyone interested in
knowing how code gets committed into Django core. If you&#8217;re a community member
who wants to contribute code to Django, have a look at
<a class="reference internal" href="writing-code/working-with-git.html"><span class="doc">Working with Git and GitHub</span></a> instead.</p>
<div class="section" id="s-handling-pull-requests">
<span id="s-id1"></span><span id="handling-pull-requests"></span><span id="id1"></span><h2>Handling pull requests<a class="headerlink" href="#handling-pull-requests" title="Permalink to this headline">¶</a></h2>
<p>Since Django is now hosted at GitHub, many patches are provided in the form of
pull requests.</p>
<p>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. In practice however, committers - who will likely
be more familiar with the commit guidelines - may decide to bring a commit up
to standard themselves.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Before merging, but after reviewing, have Jenkins test the pull request by
commenting &#8220;buildbot, test this please&#8221; on the PR.
See our <a class="reference external" href="https://code.djangoproject.com/wiki/Jenkins">Jenkins wiki page</a> for more details.</p>
</div>
<p>Here is one way to commit a pull request:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># Create a new branch tracking upstream/master -- upstream is assumed</span>
<span class="c1"># to be django/django.</span>
<span class="n">git</span> <span class="n">checkout</span> <span class="o">-</span><span class="n">b</span> <span class="n">pull_xxxxx</span> <span class="n">upstream</span><span class="o">/</span><span class="n">master</span>

<span class="c1"># Download the patches from github and apply them.</span>
<span class="n">curl</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">django</span><span class="o">/</span><span class="n">django</span><span class="o">/</span><span class="n">pull</span><span class="o">/</span><span class="n">xxxxx</span><span class="o">.</span><span class="n">patch</span> <span class="o">|</span> <span class="n">git</span> <span class="n">am</span>
</pre></div>
</div>
<p>At this point, you can work on the code. Use <code class="docutils literal"><span class="pre">git</span> <span class="pre">rebase</span> <span class="pre">-i</span></code> and <code class="docutils literal"><span class="pre">git</span>
<span class="pre">commit</span> <span class="pre">--amend</span></code> to make sure the commits have the expected level of quality.
Once you&#8217;re ready:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1"># Make sure master is ready to receive changes.</span>
<span class="n">git</span> <span class="n">checkout</span> <span class="n">master</span>
<span class="n">git</span> <span class="n">pull</span> <span class="n">upstream</span> <span class="n">master</span>
<span class="c1"># Merge the work as &quot;fast-forward&quot; to master, to avoid a merge commit.</span>
<span class="n">git</span> <span class="n">merge</span> <span class="o">--</span><span class="n">ff</span><span class="o">-</span><span class="n">only</span> <span class="n">pull_xxxxx</span>
<span class="c1"># Check that only the changes you expect will be pushed to upstream.</span>
<span class="n">git</span> <span class="n">push</span> <span class="o">--</span><span class="n">dry</span><span class="o">-</span><span class="n">run</span> <span class="n">upstream</span> <span class="n">master</span>
<span class="c1"># Push!</span>
<span class="n">git</span> <span class="n">push</span> <span class="n">upstream</span> <span class="n">master</span>

<span class="c1"># Get rid of the pull_xxxxx branch.</span>
<span class="n">git</span> <span class="n">branch</span> <span class="o">-</span><span class="n">d</span> <span class="n">pull_xxxxx</span>
</pre></div>
</div>
<p>An alternative is to add the contributor&#8217;s repository as a new remote,
checkout the branch and work from there:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">remote</span> <span class="n">add</span> <span class="o">&lt;</span><span class="n">contributor</span><span class="o">&gt;</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/&lt;</span><span class="n">contributor</span><span class="o">&gt;/</span><span class="n">django</span><span class="o">.</span><span class="n">git</span>
<span class="n">git</span> <span class="n">checkout</span> <span class="n">pull_xxxxx</span> <span class="o">&lt;</span><span class="n">contributor</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">contributor</span><span class="s1">&#39;s pull request branch&gt;</span>
</pre></div>
</div>
<p>Yet another alternative is to fetch the branch without adding the
contributor&#8217;s repository as a remote:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">fetch</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/&lt;</span><span class="n">contributor</span><span class="o">&gt;/</span><span class="n">django</span><span class="o">.</span><span class="n">git</span> <span class="o">&lt;</span><span class="n">contributor</span><span class="s1">&#39;s pull request branch&gt;</span>
<span class="n">git</span> <span class="n">checkout</span> <span class="o">-</span><span class="n">b</span> <span class="n">pull_xxxxx</span> <span class="n">FETCH_HEAD</span>
</pre></div>
</div>
<p>At this point, you can work on the code and continue as above.</p>
<p>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&#8217;t
possible to check that the tests pass and that the docs build without
downloading the changes to your development environment.</p>
<p>When rewriting the commit history of a pull request, the goal is to make
Django&#8217;s commit history as usable as possible:</p>
<ul class="simple">
<li>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.</li>
<li>Separate changes to different commits by logical grouping: if you do a
stylistic cleanup at the same time as you do other changes to a file,
separating the changes into two different commits will make reviewing
history easier.</li>
<li>Beware of merges of upstream branches in the pull requests.</li>
<li>Tests should pass and docs should build after each commit. Neither the
tests nor the docs should emit warnings.</li>
<li>Trivial and small patches usually are best done in one commit. Medium to
large work should be split into multiple commits if possible.</li>
</ul>
<p>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 a usable commit history.</p>
</div>
<div class="section" id="s-committing-guidelines">
<span id="s-id2"></span><span id="committing-guidelines"></span><span id="id2"></span><h2>Committing guidelines<a class="headerlink" href="#committing-guidelines" title="Permalink to this headline">¶</a></h2>
<p>In addition, please follow the following guidelines when committing code to
Django&#8217;s Git repository:</p>
<ul>
<li><p class="first">Never change the published history of django/django branches! <strong>Never force-
push your changes to django/django.</strong> If you absolutely must (for security
reasons for example) first discuss the situation with the core team.</p>
</li>
<li><p class="first">For any medium-to-big changes, where &#8220;medium-to-big&#8221; is according to
your judgment, please bring things up on the <a class="reference internal" href="../mailing-lists.html#django-developers-mailing-list"><span class="std std-ref">django-developers</span></a>
mailing list before making the change.</p>
<p>If you bring something up on <a class="reference internal" href="../mailing-lists.html#django-developers-mailing-list"><span class="std std-ref">django-developers</span></a> and nobody responds,
please don&#8217;t take that to mean your idea is great and should be
implemented immediately because nobody contested it. Django&#8217;s core
developers don&#8217;t have a lot of time to read mailing-list discussions
immediately, so you may have to wait a couple of days before getting a
response.</p>
</li>
<li><p class="first">Write detailed commit messages in the past tense, not present tense.</p>
<ul class="simple">
<li>Good: &#8220;Fixed Unicode bug in RSS API.&#8221;</li>
<li>Bad: &#8220;Fixes Unicode bug in RSS API.&#8221;</li>
<li>Bad: &#8220;Fixing Unicode bug in RSS API.&#8221;</li>
</ul>
<p>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:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Fixed</span> <span class="c1">#18307 -- Added git workflow guidelines</span>

<span class="n">Refactored</span> <span class="n">the</span> <span class="n">Django</span><span class="s1">&#39;s documentation to remove mentions of SVN</span>
<span class="n">specific</span> <span class="n">tasks</span><span class="o">.</span> <span class="n">Added</span> <span class="n">guidelines</span> <span class="n">of</span> <span class="n">how</span> <span class="n">to</span> <span class="n">use</span> <span class="n">Git</span><span class="p">,</span> <span class="n">GitHub</span><span class="p">,</span> <span class="ow">and</span>
<span class="n">how</span> <span class="n">to</span> <span class="n">use</span> <span class="n">pull</span> <span class="n">request</span> <span class="n">together</span> <span class="k">with</span> <span class="n">Trac</span> <span class="n">instead</span><span class="o">.</span>
</pre></div>
</div>
<p>If the patch wasn&#8217;t a pull request, you should credit the contributors in
the commit message: &#8220;Thanks A for report, B for the patch and C for the
review.&#8221;</p>
</li>
<li><p class="first">For commits to a branch, prefix the commit message with the branch name.
For example: &#8220;[1.4.x] Fixed #xxxxx &#8211; Added support for mind reading.&#8221;</p>
</li>
<li><p class="first">Limit commits to the most granular change that makes sense. This means,
use frequent small commits rather than infrequent large commits. For
example, if implementing feature X requires a small change to library Y,
first commit the change to library Y, then commit feature X in a
separate commit. This goes a <em>long way</em> in helping all Django core
developers follow your changes.</p>
</li>
<li><p class="first">Separate bug fixes from feature changes. Bugfixes may need to be backported
to the stable branch, according to the <a class="reference internal" href="../release-process.html#backwards-compatibility-policy"><span class="std std-ref">backwards-compatibility policy</span></a>.</p>
</li>
<li><p class="first">If your commit closes a ticket in the Django <a class="reference external" href="https://code.djangoproject.com/newticket">ticket tracker</a>, begin
your commit message with the text &#8220;Fixed #xxxxx&#8221;, where &#8220;xxxxx&#8221; is the
number of the ticket your commit fixes. Example: &#8220;Fixed #123 &#8211; Added
whizbang feature.&#8221;. We&#8217;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.</p>
<p>If your commit closes a ticket and is in a branch, use the branch name
first, then the &#8220;Fixed #xxxxx.&#8221; For example:
&#8220;[1.4.x] Fixed #123 &#8211; Added whizbang feature.&#8221;</p>
<p>For the curious, we&#8217;re using a <a class="reference external" href="https://github.com/aaugustin/trac-github">Trac plugin</a> for this.</p>
</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Note that the Trac integration doesn&#8217;t know anything about pull requests.
So if you try to close a pull request with the phrase &#8220;closes #400&#8221; in your
commit message, GitHub will close the pull request, but the Trac plugin
will also close the same numbered ticket in Trac.</p>
</div>
<ul>
<li><p class="first">If your commit references a ticket in the Django <a class="reference external" href="https://code.djangoproject.com/newticket">ticket tracker</a> but
does <em>not</em> close the ticket, include the phrase &#8220;Refs #xxxxx&#8221;, where &#8220;xxxxx&#8221;
is the number of the ticket your commit references. This will automatically
post a comment to the appropriate ticket.</p>
</li>
<li><p class="first">Write commit messages for backports using this pattern:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">[</span><span class="o">&lt;</span><span class="n">Django</span> <span class="n">version</span><span class="o">&gt;</span><span class="p">]</span> <span class="n">Fixed</span> <span class="o">&lt;</span><span class="n">ticket</span><span class="o">&gt;</span> <span class="o">--</span> <span class="o">&lt;</span><span class="n">description</span><span class="o">&gt;</span>

<span class="n">Backport</span> <span class="n">of</span> <span class="o">&lt;</span><span class="n">revision</span><span class="o">&gt;</span> <span class="kn">from</span> <span class="o">&lt;</span><span class="n">branch</span><span class="o">&gt;.</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">[</span><span class="mf">1.3</span><span class="o">.</span><span class="n">x</span><span class="p">]</span> <span class="n">Fixed</span> <span class="c1">#17028 -- Changed diveintopython.org -&gt; diveintopython.net.</span>

<span class="n">Backport</span> <span class="n">of</span> <span class="mi">80</span><span class="n">c0cbf1c97047daed2c5b41b296bbc56fe1d7e3</span> <span class="kn">from</span> <span class="nn">master.</span>
</pre></div>
</div>
</li>
</ul>
</div>
<div class="section" id="s-reverting-commits">
<span id="reverting-commits"></span><h2>Reverting commits<a class="headerlink" href="#reverting-commits" title="Permalink to this headline">¶</a></h2>
<p>Nobody&#8217;s perfect; mistakes will be committed.</p>
<p>But try very hard to ensure that mistakes don&#8217;t happen. Just because we have a
reversion policy doesn&#8217;t relax your responsibility to aim for the highest
quality possible. Really: double-check your work, or have it checked by
another committer, <strong>before</strong> you commit it in the first place!</p>
<p>When a mistaken commit is discovered, please follow these guidelines:</p>
<ul class="simple">
<li>If possible, have the original author revert their own commit.</li>
<li>Don&#8217;t revert another author&#8217;s changes without permission from the
original author.</li>
<li>Use git revert &#8211; this will make a reverse commit, but the original
commit will still be part of the commit history.</li>
<li>If the original author can&#8217;t be reached (within a reasonable amount
of time &#8211; a day or so) and the problem is severe &#8211; crashing bug,
major test failures, etc &#8211; then ask for objections on the
<a class="reference internal" href="../mailing-lists.html#django-developers-mailing-list"><span class="std std-ref">django-developers</span></a> mailing list then revert if there are none.</li>
<li>If the problem is small (a feature commit after feature freeze,
say), wait it out.</li>
<li>If there&#8217;s a disagreement between the committer and the
reverter-to-be then try to work it out on the <a class="reference internal" href="../mailing-lists.html#django-developers-mailing-list"><span class="std std-ref">django-developers</span></a>
mailing list. If an agreement can&#8217;t be reached then it should
be put to a vote.</li>
<li>If the commit introduced a confirmed, disclosed security
vulnerability then the commit may be reverted immediately without
permission from anyone.</li>
<li>The release branch maintainer may back out commits to the release
branch without permission if the commit breaks the release branch.</li>
<li>If you mistakenly push a topic branch to django/django, just delete it.
For instance, if you did: <code class="docutils literal"><span class="pre">git</span> <span class="pre">push</span> <span class="pre">upstream</span> <span class="pre">feature_antigravity</span></code>,
just do a reverse push: <code class="docutils literal"><span class="pre">git</span> <span class="pre">push</span> <span class="pre">upstream</span> <span class="pre">:feature_antigravity</span></code>.</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Committing code</a><ul>
<li><a class="reference internal" href="#handling-pull-requests">Handling pull requests</a></li>
<li><a class="reference internal" href="#committing-guidelines">Committing guidelines</a></li>
<li><a class="reference internal" href="#reverting-commits">Reverting commits</a></li>
</ul>
</li>
</ul>

  <h3>Browse</h3>
  <ul>
    
      <li>Prev: <a href="localizing.html">Localizing Django</a></li>
    
    
      <li>Next: <a href="../mailing-lists.html">Mailing lists</a></li>
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../../index.html">Django 1.8.19 documentation</a>
        
          <ul><li><a href="../index.html">Django internals</a>
        
          <ul><li><a href="index.html">Contributing to Django</a>
        
        <ul><li>Committing code</li></ul>
        </li></ul></li></ul>
      </li>
  </ul>

  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/internals/contributing/committing-code.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Mar 10, 2018</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="localizing.html" title="Localizing Django">previous</a>
     |
    <a href="../index.html" title="Django internals" accesskey="U">up</a>
   |
    <a href="../mailing-lists.html" title="Mailing lists">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>