{"title":"Confirmando código","version":"6.0","locale":"es","docname":"internals/contributing/committing-code","url":"/es/6.0/internals/contributing/committing-code/","canonical":"https://djangodocs.dev/es/6.0/internals/contributing/committing-code/","summary":"This section is addressed to the mergers and to anyone interested in knowing how code gets committed into Django.","html":"<h1>Confirmando código<a class=\"heading-anchor\" href=\"#committing-code\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>This section is addressed to the mergers and to anyone interested in knowing\nhow code gets committed into Django. The <a class=\"reference internal\" href=\"#committing-guidelines\"><span class=\"std std-ref\">Directrices de compromiso</span></a> apply\nto all contributors, with or without commit rights.</p>\n<p>If you’re a community member who wants to contribute code to Django, look at\n<a class=\"reference internal\" href=\"/es/6.0/internals/contributing/writing-code/working-with-git/\"><span class=\"doc\">Working with Git and GitHub</span></a> instead.</p>\n<section id=\"handling-pull-requests\">\n<span id=\"id1\"></span><h2>Gestionando las pull requests<a class=\"heading-anchor\" href=\"#handling-pull-requests\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Dado que Django está alojado en GitHub, los parches se proporcionan en forma de pull requests.</p>\n<p>Cuando envíe una solicitud de extracción, asegúrese de que cada una de ellas se ajusta a las directrices que se describen a continuación. Se espera que los colaboradores proporcionen los mejores pull requests posibles. En la práctica, las fusiones, que probablemente estarán más familiarizadas con las directrices de confirmación, pueden decidir actualizar ellas mismas una confirmación.</p>\n<p>Es posible que desee que las acciones de Jenkins o GitHub prueben el pull request con uno de los constructores de pull request que no se ejecuta automáticamente, como Oracle o Selenium. Consulte la página wiki <a class=\"reference external\" href=\"https://code.djangoproject.com/wiki/CI\">CI</a> para obtener instrucciones.</p>\n<p>Si te encuentras revisando pull requests localmente más a menudo, este alias de git te será útil:</p>\n<div class=\"code-block\" data-language=\"ini\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Ini</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Ini code\"><code><span class=\"k\">[alias]</span>\n    <span class=\"na\">pr</span> <span class=\"o\">=</span> <span class=\"s\">!sh -c \\&quot;git fetch upstream pull/${1}/head:pr/${1} &amp;&amp; git checkout pr/${1}\\&quot;</span>\n</code></pre></div>\n<p>Añádelo a tu <code class=\"docutils literal notranslate\">~/.gitconfig</code>, y establece <code class=\"docutils literal notranslate\">upstream</code> como <code class=\"docutils literal notranslate\">django/django</code>. Luego puedes ejecutar <code class=\"docutils literal notranslate\">git pr ####</code> para obtener el pull request correspondiente.</p>\n<p>En este punto, puedes trabajar en el código. Utiliza <code class=\"docutils literal notranslate\">git rebase -i</code> y <code class=\"docutils literal notranslate\">git commit --amend</code> para asegurarte de que los commits tienen el nivel de calidad esperado. Una vez que estés listo:</p>\n<div class=\"console\" data-console><div class=\"console-panel\" data-platform=\"unix\"><p class=\"console-label\" id=\"console-0-unix-label\">Linux / macOS</p><div class=\"code-block\" data-language=\"console\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"gp\">$ </span><span class=\"c1\"># Pull in the latest changes from main.</span>\n<span class=\"gp\">$ </span>git checkout main\n<span class=\"gp\">$ </span>git pull upstream main\n<span class=\"gp\">$ </span><span class=\"c1\"># Rebase the pull request on main.</span>\n<span class=\"gp\">$ </span>git checkout pr/####\n<span class=\"gp\">$ </span>git rebase main\n<span class=\"gp\">$ </span>git checkout main\n<span class=\"gp\">$ </span><span class=\"c1\"># Merge the work as &quot;fast-forward&quot; to main to avoid a merge commit.</span>\n<span class=\"gp\">$ </span><span class=\"c1\"># (in practice, you can omit &quot;--ff-only&quot; since you just rebased)</span>\n<span class=\"gp\">$ </span>git merge --ff-only pr/XXXX\n<span class=\"gp\">$ </span><span class=\"c1\"># If you&#39;re not sure if you did things correctly, check that only the</span>\n<span class=\"gp\">$ </span><span class=\"c1\"># changes you expect will be pushed to upstream.</span>\n<span class=\"gp\">$ </span>git push --dry-run upstream main\n<span class=\"gp\">$ </span><span class=\"c1\"># Push!</span>\n<span class=\"gp\">$ </span>git push upstream main\n<span class=\"gp\">$ </span><span class=\"c1\"># Delete the pull request branch.</span>\n<span class=\"gp\">$ </span>git branch -d pr/xxxx\n</code></pre></div>\n</div><div class=\"console-panel\" data-platform=\"windows\"><p class=\"console-label\" id=\"console-0-windows-label\">Windows</p><div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows shell\"><code><span class=\"gp\">...\\&gt;</span> <span class=\"c1\">REM Pull in the latest changes from main.</span>\n<span class=\"gp\">...\\&gt;</span> git checkout main\n<span class=\"gp\">...\\&gt;</span> git pull upstream main\n<span class=\"gp\">...\\&gt;</span> <span class=\"c1\">REM Rebase the pull request on main.</span>\n<span class=\"gp\">...\\&gt;</span> git checkout pr/####\n<span class=\"gp\">...\\&gt;</span> git rebase main\n<span class=\"gp\">...\\&gt;</span> git checkout main\n<span class=\"gp\">...\\&gt;</span> <span class=\"c1\">REM Merge the work as &quot;fast-forward&quot; to main to avoid a merge commit.</span>\n<span class=\"gp\">...\\&gt;</span> <span class=\"c1\">REM (in practice, you can omit &quot;--ff-only&quot; since you just rebased)</span>\n<span class=\"gp\">...\\&gt;</span> git merge --ff-only pr/XXXX\n<span class=\"gp\">...\\&gt;</span> <span class=\"c1\">REM If you&#39;re not sure if you did things correctly, check that only the</span>\n<span class=\"gp\">...\\&gt;</span> <span class=\"c1\">REM changes you expect will be pushed to upstream.</span>\n<span class=\"gp\">...\\&gt;</span> git push --dry-run upstream main\n<span class=\"gp\">...\\&gt;</span> <span class=\"c1\">REM Push!</span>\n<span class=\"gp\">...\\&gt;</span> git push upstream main\n<span class=\"gp\">...\\&gt;</span> <span class=\"c1\">REM Delete the pull request branch.</span>\n<span class=\"gp\">...\\&gt;</span> git branch -d pr/xxxx\n</code></pre></div></div></div>\n<p>Fuerza el push a la rama después de hacer el rebasing en main pero antes de hacer el merging y el push a upstream. Esto permite que los hashes de commit en main y en la rama coincidan, lo que cierra automáticamente la solicitud de pull.</p>\n<p>Si no es necesario fusionar una pull request en varias confirmaciones, puede utilizar el botón «Squash and merge» de GitHub en el sitio web. Edite el mensaje de confirmación según sea necesario para que se ajuste a <a class=\"reference internal\" href=\"#committing-guidelines\"><span class=\"std std-ref\">las directrices</span></a> y elimine el número de solicitud de extracción que se añade automáticamente a la primera línea del mensaje.</p>\n<p>Al reescribir el historial de commits de un pull request, el objetivo es hacer que el historial de commits de Django sea lo más usable posible:</p>\n<ul class=\"simple\">\n<li><p>Si un parche contiene confirmaciones de ida y vuelta, reescríbalas en una sola. Por ejemplo, si una confirmación añade algo de código y una segunda corrige problemas estilísticos introducidos en la primera, esas confirmaciones deben aplastarse antes de fusionarse.</p></li>\n<li><p>Separe los cambios en diferentes commits mediante una agrupación lógica: si realiza una limpieza estilística al mismo tiempo que realiza otros cambios en un archivo, separar los cambios en dos commits diferentes facilitará la revisión del historial.</p></li>\n<li><p>Cuidado con las fusiones de ramas ascendentes en los pull requests.</p></li>\n<li><p>Las pruebas deben pasar y los documentos deben compilarse después de cada confirmación. Ni las pruebas ni los documentos deben emitir advertencias.</p></li>\n<li><p>Los parches pequeños y triviales suelen realizarse mejor en una sola confirmación. Los trabajos medianos y grandes pueden dividirse en varias confirmaciones si tiene sentido.</p></li>\n</ul>\n<p>La practicidad vence a la pureza, así que depende de cada fusión decidir cuánta manipulación de la historia hacer para un pull request. Los puntos principales son involucrar a la comunidad, hacer el trabajo y tener un historial de commit utilizable.</p>\n</section>\n<section id=\"committing-guidelines\">\n<span id=\"id2\"></span><h2>Directrices de compromiso<a class=\"heading-anchor\" href=\"#committing-guidelines\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>These guidelines apply to all commits to Django’s Git repository, whether\nsubmitted by a contributor via a pull request or landed directly by a merger:</p>\n<ul>\n<li><p>Nunca cambies el historial publicado de las ramas <code class=\"docutils literal notranslate\">django/django</code> forzando el push. Si es absolutamente necesario (por razones de seguridad, por ejemplo), primero discute la situación con el equipo.</p></li>\n<li><p>Para cualquier cambio de mediano a gran escala, donde «mediano a gran escala» queda a su criterio, por favor, coméntelo en el <a class=\"reference external\" href=\"https://forum.djangoproject.com/\">Foro Django</a> antes de realizar el cambio.</p>\n<p>Si plantea algo y nadie responde, por favor, no asuma que su idea es excelente y debe implementarse de inmediato solo por que nadie la cuestiono. No todo el mundo tiene mucho tiempo para leer las discuciones de inmediato, así que es posible que tenga que esperar un par de días antes de recibir una respuesta.</p>\n</li>\n<li><p>Write detailed commit messages in the past tense, not present tense, and\nend the subject line with a period.</p>\n<ul class=\"simple\">\n<li><p>Correct: «Fixed Unicode bug in RSS API.»</p></li>\n<li><p>Incorrect: «Fixes Unicode bug in RSS API.» (present tense)</p></li>\n<li><p>Incorrect: «Fixing Unicode bug in RSS API.» («-ing» form)</p></li>\n<li><p>Incorrect: «Fixed Unicode bug in RSS API» (missing trailing period)</p></li>\n</ul>\n<p>The commit message should be in lines of 72 chars maximum. There should be\na subject line, separated by a blank line and then paragraphs of 72 char\nlines. The limits are soft. For the subject line, shorter is better.</p>\n<p>In the body of the commit message more detail is better than less, and should\nexplain <em>why</em> the change was made, not <em>what</em> was changed or <em>how</em>. The code\nitself shows what changed; the commit message should provide the context and\nreasoning that the code cannot.</p>\n<p>Credit the contributors in the commit message: «Thanks A for the report and B\nfor review.» Use git’s <a class=\"reference external\" href=\"https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors\">Co-Authored-By</a> as appropriate, including anyone\nwhose earlier work the change builds on.</p>\n<p>Por ejemplo:</p>\n<div class=\"code-block\" data-language=\"none\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">None</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"None code\"><code>Fixed #18307 -- Added git workflow guidelines.\n\nRefactored the Django&#39;s documentation to remove mentions of SVN\nspecific tasks. Added guidelines of how to use Git, GitHub, and\nhow to use pull request together with Trac instead.\n\nThanks to Full Name for the report, and to Reviewer for reviews.\n</code></pre></div>\n</li>\n<li><p>For commits to a branch, prefix the commit message with the branch name.\nFor example: «[1.4.x] Fixed #xxxxx – Added support for mind reading.»</p></li>\n<li><p>Limit commits to the most granular change that makes sense. This means,\nuse frequent small commits rather than infrequent large commits. For\nexample, if implementing feature X requires a small change to library Y,\nfirst commit the change to library Y, then commit feature X in a separate\ncommit. This goes a <em>long way</em> in helping everyone follow your changes.</p></li>\n<li><p>Separate bug fixes from feature changes. Bugfixes may need to be backported\nto the stable branch, according to <a class=\"reference internal\" href=\"/es/6.0/internals/release-process/#supported-versions-policy\"><span class=\"std std-ref\">Supported versions</span></a>.</p></li>\n<li><p>If your commit closes a ticket in the Django <a class=\"reference external\" href=\"https://code.djangoproject.com/\">ticket tracker</a>, begin\nyour commit message with the text «Fixed #xxxxx», where «xxxxx» is the\nnumber of the ticket your commit fixes. Example: «Fixed #123 – Added\nwhizbang feature.». We’ve rigged Trac so that any commit message in that\nformat will automatically close the referenced ticket and post a comment\nto it with the full commit message.</p>\n<p>For the curious, we’re using a <a class=\"reference external\" href=\"https://github.com/trac-hacks/trac-github\">Trac plugin</a> for this.</p>\n</li>\n</ul>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Nota</p>\n<p>Note that the Trac integration doesn’t know anything about pull requests.\nSo if you try to close a pull request with the phrase «closes #400» in your\ncommit message, GitHub will close the pull request, but the Trac plugin\nwill not close the same numbered ticket in Trac.</p>\n</aside>\n<ul>\n<li><p>If your commit references a ticket in the Django <a class=\"reference external\" href=\"https://code.djangoproject.com/\">ticket tracker</a> but\ndoes <em>not</em> close the ticket, include the phrase «Refs #xxxxx», where «xxxxx»\nis the number of the ticket your commit references. This will automatically\npost a comment to the appropriate ticket.</p></li>\n<li><p>Write commit messages for backports using this pattern:</p>\n<div class=\"code-block\" data-language=\"none\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">None</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"None code\"><code>[&lt;Django version&gt;] Fixed &lt;ticket&gt; -- &lt;description&gt;\n\nBackport of &lt;revision&gt; from &lt;branch&gt;.\n</code></pre></div>\n<p>Por ejemplo:</p>\n<div class=\"code-block\" data-language=\"none\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">None</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"None code\"><code>[1.3.x] Fixed #17028 -- Changed diveintopython.org -&gt; diveintopython.net.\n\nBackport of 80c0cbf1c97047daed2c5b41b296bbc56fe1d7e3 from main.\n</code></pre></div>\n<p>There’s a <a class=\"reference external\" href=\"https://code.djangoproject.com/wiki/MergerTips#AutomatingBackports\">script on the wiki</a> to\nautomate this.</p>\n<p>If the commit fixes a regression, include this in the commit message:</p>\n<div class=\"code-block\" data-language=\"none\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">None</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"None code\"><code>Regression in 6ecccad711b52f9273b1acb07a57d3f806e93928.\n</code></pre></div>\n<p>(use the commit hash where the regression was introduced).</p>\n</li>\n</ul>\n</section>\n<section id=\"reverting-commits\">\n<h2>Reverting commits<a class=\"heading-anchor\" href=\"#reverting-commits\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Nobody’s perfect; mistakes will be committed.</p>\n<p>But try very hard to ensure that mistakes don’t happen. Just because we have a\nreversion policy doesn’t relax your responsibility to aim for the highest\nquality possible. Really: double-check your work, or have it checked by\nanother merger <strong>before</strong> you commit it in the first place!</p>\n<p>When a mistaken commit is discovered, please follow these guidelines:</p>\n<ul class=\"simple\">\n<li><p>If possible, have the original author revert their own commit.</p></li>\n<li><p>Don’t revert another author’s changes without permission from the\noriginal author.</p></li>\n<li><p>Use git revert – this will make a reverse commit, but the original\ncommit will still be part of the commit history.</p></li>\n<li><p>If the original author can’t be reached (within a reasonable amount\nof time – a day or so) and the problem is severe – crashing bug,\nmajor test failures, etc. – then ask for objections on the <a class=\"reference external\" href=\"https://forum.djangoproject.com/\">Django Forum</a>\nthen revert if there are none.</p></li>\n<li><p>If the problem is small (a feature commit after feature freeze,\nsay), wait it out.</p></li>\n<li><p>If there’s a disagreement between the merger and the reverter-to-be then try\nto work it out on the <a class=\"reference external\" href=\"https://forum.djangoproject.com/\">Django Forum</a> . If an agreement can’t be reached then\nit should be put to a vote.</p></li>\n<li><p>If the commit introduced a confirmed, disclosed security\nvulnerability then the commit may be reverted immediately without\npermission from anyone.</p></li>\n<li><p>The release branch maintainer may back out commits to the release\nbranch without permission if the commit breaks the release branch.</p></li>\n<li><p>If you mistakenly push a topic branch to <code class=\"docutils literal notranslate\">django/django</code>, delete it.\nFor instance, if you did: <code class=\"docutils literal notranslate\">git push upstream feature_antigravity</code>,\ndo a reverse push: <code class=\"docutils literal notranslate\">git push upstream :feature_antigravity</code>.</p></li>\n</ul>\n</section>","rootId":"committing-code","toc":[{"title":"Gestionando las pull requests","anchor":"handling-pull-requests","children":[]},{"title":"Directrices de compromiso","anchor":"committing-guidelines","children":[]},{"title":"Reverting commits","anchor":"reverting-commits","children":[]}],"breadcrumbs":[{"docname":"internals/index","title":"Django internals","url":"/es/6.0/internals/"},{"docname":"internals/contributing/index","title":"Contribuyendo con Django","url":"/es/6.0/internals/contributing/"},{"docname":"internals/contributing/writing-code/index","title":"Contributing code","url":"/es/6.0/internals/contributing/writing-code/"}],"prev":{"docname":"internals/contributing/accessibility","title":"Accesibilidad","url":"/es/6.0/internals/contributing/accessibility/"},"next":{"docname":"internals/contributing/writing-documentation","title":"Writing documentation","url":"/es/6.0/internals/contributing/writing-documentation/"},"formats":{"html":"/es/6.0/internals/contributing/committing-code/","markdown":"/es/6.0/internals/contributing/committing-code.md","json":"/es/6.0/internals/contributing/committing-code.json"},"source":"https://github.com/django/django/blob/stable/6.0.x/docs/internals/contributing/committing-code.txt","official":"https://docs.djangoproject.com/es/6.0/internals/contributing/committing-code/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}