---
title: "Cód tiomanta"
version: 6.1
locale: ga
source: https://docs.djangoproject.com/ga/6.1/internals/contributing/committing-code/
canonical: https://djangodocs.dev/ga/6.1/internals/contributing/committing-code/
---
# Cód tiomanta

This section is addressed to the mergers and to anyone interested in knowing
how code gets committed into Django. The [Treoirlínte a](#committing-guidelines) apply
to all contributors, with or without commit rights.

If you're a community member who wants to contribute code to Django, look at
[Ag obair le Git agus GitHub](/ga/6.1/internals/contributing/writing-code/working-with-git/) instead.

## Iarrataí tarraingthe a

Ós rud é go bhfuil Django á óstáil ar GitHub, cuirtear paistí ar fáil i bhfoirm iarratais tarraingthe.

Agus iarratas tarraingthe á dhéanamh agat, déan cinnte go gcomhlíonann gach tiomantas aonair na treoirlínte tiomanta Táthar ag súil go soláthróidh ranníocóirí na hiarratais tarraingthe is fearr Go praiticiúil féadfaidh cumaisc - a mbeidh níos eolaí ar na treoirlínte tiomanta - cinneadh a dhéanamh tiomantas a thabhairt suas go dtí an caighdeán iad féin.

B'fhéidir gur mhaith leat gníomhartha Jenkins nó GitHub a thástáil ar an iarratas tarraingthe le duine de na tógálaithe iarratais tarraingthe nach ritheann go huathoibríoch, mar shampla Oracle nó Selenium. Féach an leathanach wiki CI \_ le haghaidh treoracha.

Má aimsíonn tú tú féin ag seiceáil iarratais tarraingthe go háitiúil níos minice, beidh an t-alias git seo cabhrach:

```ini
[alias]
    pr = !sh -c \"git fetch upstream pull/${1}/head:pr/${1} && git checkout pr/${1}\"
```

Cuir é le do `~/.gitconfig`, agus socraigh `upstream` mar `django/django`. Ansin is féidir leat `git pr ####` a rith chun an t-iarratas tarraingthe comhfhreagrach a sheiceáil.

Ag an bpointe seo, is féidir leat oibriú ar an gcód. Úsáid `git rebase -i` agus `git commit --amend` chun a chinntiú go bhfuil an leibhéal cáilíochta ag súil leis ag na gealltanais. Nuair a bheidh tú réidh:

```console
$ # Pull in the latest changes from main.
$ git checkout main
$ git pull upstream main
$ # Rebase the pull request on main.
$ git checkout pr/####
$ git rebase main
$ git checkout main
$ # Merge the work as "fast-forward" to main to avoid a merge commit.
$ # (in practice, you can omit "--ff-only" since you just rebased)
$ git merge --ff-only pr/XXXX
$ # If you're not sure if you did things correctly, check that only the
$ # changes you expect will be pushed to upstream.
$ git push --dry-run upstream main
$ # Push!
$ git push upstream main
$ # Delete the pull request branch.
$ git branch -d pr/xxxx
```

*Windows*

```doscon
...\> REM Pull in the latest changes from main.
...\> git checkout main
...\> git pull upstream main
...\> REM Rebase the pull request on main.
...\> git checkout pr/####
...\> git rebase main
...\> git checkout main
...\> REM Merge the work as "fast-forward" to main to avoid a merge commit.
...\> REM (in practice, you can omit "--ff-only" since you just rebased)
...\> git merge --ff-only pr/XXXX
...\> REM If you're not sure if you did things correctly, check that only the
...\> REM changes you expect will be pushed to upstream.
...\> git push --dry-run upstream main
...\> REM Push!
...\> git push upstream main
...\> REM Delete the pull request branch.
...\> git branch -d pr/xxxx
```

Fórsa brú go dtí an brainse tar éis athbhunú ar an bpríomhlíonra ach roimh chumasc agus brú go dtí an sruth. Ligeann sé seo do na hashes geallta ar an bpríomhlíonra agus an brainse a mheaitseáil a dhúnann an t-iarratas tarraingt go huathoibríoch.

Mura gá iarraidh tarraingthe a chumasc mar ghealltanais iolracha, is féidir leat cnaipe “Squash agus cumaisc” GitHub a úsáid ar an suíomh Gréasáin. Cuir an teachtaireacht \<committing-guidelines\>tiomanta in eagar de réir mar is gá chun comhlíonadh la:ref: na treoirlínte agus bain an uimhir iarratais tarraingthe a chuirtear isteach go huathoibríoch le chéad líne na teachtaireachta.

Agus stair thiomanta iarratais tarraingthe á athscríobh agat, is é an aidhm stair thiomanta Django a dhéanamh chomh inúsáidte agus is féidir:

- Má tá gealltanais anar-anall i bpaiste, ansin iad sin a athscríobh i gceann amháin. Mar shampla, má chuireann tiomantas cód éigin leis agus má shocraíonn an dara tiomantas saincheisteanna stíleacha a tugadh isteach sa chéad thiomantas, ba chóir na gealltanais sin a scriosadh sula ndéantar iad a chumasc.
- Athruithe ar leithligh ar ghealltanais éagsúla trí ghrúpáil loighciúil: má dhéanann tú glantachán stíle ag an am céanna agus a dhéanann tú athruithe eile ar chomhad, beidh sé níos fusa athbhreithniú a dhéanamh ar an stair trí na hathruithe a roinnt ina dhá ghealltanas éagsúla.
- Bí cúramach le cumaisc brainsí suas srutha sna hiarratais tarraingthe.
- Ba chóir go rith na tástálacha agus ba chóir doiciméid a thógáil tar éis gach Níor chóir do na tástálacha ná na doiciméid rabhaidh a eisiúint.
- Is fearr paistí triobhála agus beaga de ghnáth a dhéanamh i dtiomantas amháin. Féadfar obair mheánmhéide go mór a roinnt ina iliomad gealltanais má tá ciall aige.

Buaileann praiticiúlacht íonacht, mar sin tá sé faoi gach cumaisc cinneadh a dhéanamh cé mhéad staire atá le déanamh le haghaidh iarratas tarraingthe. Is iad na príomhphointí ná an pobal a mhealladh, obair a dhéanamh, agus stair tiomanta inúsáidte a bheith agat.

## Treoirlínte a

These guidelines apply to all commits to Django's Git repository, whether
submitted by a contributor via a pull request or landed directly by a merger:

- Ná athraigh stair foilsithe brainsí `django/django` trí bhrú fórsa. Más gá duit go hiomlán (ar chúiseanna slándála mar shampla), plé an cás leis an bhfoireann ar dtús.
- For any medium-to-big changes, where "medium-to-big" is according to
  your judgment, please bring things up on the [Django Forum](https://forum.djangoproject.com/) before making
  the change.

  If you bring something up and nobody responds, please don't take that
  to mean your idea is great and should be implemented immediately because
  nobody contested it. Everyone doesn't always have a lot of time to read
  discussions immediately, so you may have to wait a couple of days before
  getting a response.
- Write detailed commit messages in the past tense, not present tense, and
  end the subject line with a period.

  - Correct: "Fixed Unicode bug in RSS API."
  - Incorrect: "Fixes Unicode bug in RSS API." (present tense)
  - Incorrect: "Fixing Unicode bug in RSS API." ("-ing" form)
  - Incorrect: "Fixed Unicode bug in RSS API" (missing trailing period)

  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, and should
  explain *why* the change was made, not *what* was changed or *how*. The code
  itself shows what changed; the commit message should provide the context and
  reasoning that the code cannot.

  Credit the contributors in the commit message: "Thanks A for the report and B
  for review." Use git's [Co-Authored-By](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors) as appropriate, including anyone
  whose earlier work the change builds on.

  Mar shampla:

  ```
  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.

  Thanks to Full Name for the report, and to Reviewer for reviews.
  ```
- Tiomann teorainn don athrú is gráinneach a dhéanann ciall. Ciallaíonn sé seo, bain úsáid as gealltanais bheaga go minic seachas tiomantas móra is annamh. Mar shampla, má éilíonn athrú beag ar leabharlann Y a chur i bhfeidhm gné X, déan an t-athrú a dhéanamh ar leabharlann Y ar dtús, ansin déan gné X i dtiomantas ar leithligh. Téann sé seo\* bealach fad\* chun cabhrú le gach duine d'athruithe a leanúint.
- Separate bug fixes from feature changes. Bugfixes may need to be
  [backported](#backports).
- Má dhúnann do thiomantas ticéad sa [rianaitheoir ticéad](https://code.djangoproject.com/) Django, cuir tús le do theachtaireacht tiomanta leis an téacs “Seasta #xxxxx “, áit is é “xxxxx” uimhir an ticéad a shocraíonn do thiomantas. Sampla: “Seasta #123 -- Gné whizbang curtha leis.”. Tá Trac curtha againn ionas go ndúnfaidh aon teachtaireacht tiomanta san fhormáid sin an ticéad tagartha go huathoibríoch agus go gcuirfidh trácht air leis an teachtaireacht iomlán tiomanta.

  Maidir le daoine fiosracha, táimid ag baint úsáide as breiseán Trac \_ chuige seo.

> **Note**
>
> Tabhair faoi deara nach bhfuil aon rud ar eolas ag comhtháthú Trac faoi iarratais tarraingthe. Mar sin má dhéanann tú iarratas tarraingthe a dhúnadh leis an abairt “dúnann #400" i do theachtaireacht tiomanta, dúnfaidh GitHub an t-iarratas tarraingthe, ach ní dhúnfaidh an breiseán Trac an ticéad uimhrithe céanna i Trac.

- Má thagraíonn do thiomantas ticéad sa [rianaitheoir ticéad](https://code.djangoproject.com/) Django ach ní dhúnnaí\* an ticéad, cuir an abairt “Refs #xxxxx “san áireamh, áit ar “xxxxx” uimhir an ticéid a thagann do thiomantas. Cuirfidh sé seo trácht ar an ticéad cuí go huathoibríoch.

## Backports

Bug fix backports to stable branches are done exclusively by mergers, following
the [Leaganacha tacaithe](/ga/6.1/internals/release-process/#supported-versions-policy). A backport consists of cherry-picking a
commit from `main` onto the target `stable/A.B.x` branch.

A backport commit must include two things beyond the original commit message:

- A prefix `[A.B.x]` on the subject line, where `A.B.x` is the name of the
  `stable/A.B.x` branch being targeted.
- A suffix `Backport of <sha> from main.` line in the commit body, pointing
  to the original commit hash.

Mar shampla:

```
[1.3.x] Fixed #17028 -- Changed diveintopython.org -> diveintopython.net.

Backport of 80c0cbf1c97047daed2c5b41b296bbc56fe1d7e3 from main.
```

If the backport also fixes a regression, add a line identifying the commit that
introduced it:

```
Regression in 6ecccad711b52f9273b1acb07a57d3f806e93928.
```

There are three ways to do a backport, depending on your workflow:

**Option 1: fully manual**

Cherry-pick the commit onto the stable branch, then amend the commit message to
add the required prefix and backport note:

```shell
git cherry-pick <sha>
git commit --amend
```

If the cherry-pick produces conflicts, resolve them, stage the changes, then
run `git cherry-pick --continue` before amending. This option requires no
setup but relies entirely on remembering to format the message correctly.

**Option 2: using the helper script in the repo**

The `scripts/backport.sh` Bash script automates the cherry-pick and rewrites
the commit message with the correct prefix and backport note. Run it from the
target stable branch:

```shell
bash scripts/backport.sh <sha>
```

This is straightforward for clean cherry-picks, but if conflicts are produced,
you will need to resolve them manually and add the prefix and backport note to
the commit message yourself.

**Option 3: using the** `prepare-commit-msg` **git hook**

The `scripts/prepare_commit_msg.py` Python script can be installed as a
`prepare-commit-msg` git hook. It automatically adds the `[A.B.x]` prefix
to the subject line, appends `Backport of <sha> from main.` to the commit
body, and ensures the subject line ends with a period, even when the
cherry-pick produces conflicts. To install it, create an executable file
`.git/hooks/prepare-commit-msg` containing:

```sh
#!/bin/sh
exec python scripts/prepare_commit_msg.py "$@"
```

Once installed, a plain `git cherry-pick <sha>` on a stable branch is
sufficient; the hook handles the message formatting in all cases.

## Tiomantas a thabhairt ar ais

Níl aon duine foirfe; déanfar botúin.

Ach déan iarracht an-chrua a chinntiú nach dtarlóidh botúin. Díreach toisc go bhfuil beartas aisghabhála againn ní mhaolaítear do fhreagracht chun díriú a dhéanamh ar an gcaighdeán is airde is féidir. I ndáiríre: déan do chuid oibre a sheiceáil faoi dhó, nó déan í a sheiceáil trí chumasc eile\*\* roimhe\*\* déanann tú é sa chéad áit!

Nuair a aimsítear tiomantas mícheart, lean na treoirlínte seo le do thoil:

- Más féidir, cuir ar an údar bunaidh a thiomantas féin a chur ar ais.
- Ná cuir athruithe údair eile ar ais gan cead ón údar bunaidh.
- Úsáid git revert - déanfaidh sé seo tiomantas ar ais, ach beidh an tiomantas bunaidh fós mar chuid de stair an tiomanta.
- 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 [Django Forum](https://forum.djangoproject.com/)
  then revert if there are none.
- Má tá an fhadhb beag (gné a thiomann tar éis reoite gné, abair), fan amach í.
- If there's a disagreement between the merger and the reverter-to-be then try
  to work it out on the [Django Forum](https://forum.djangoproject.com/) . If an agreement can't be reached then
  it should be put to a vote.
- Má thug an tiomantas leochaileacht slándála dearbhaithe, nochtaithe isteach ansin féadfar an tiomantas a chur ar ais láithreach gan cead ó aon duine.
- Féadfaidh an cothabhálaí brainse scaoilte gealltanais a chur ar ais don bhrainse scaoilte gan cead má bhriseann an tiomantas an brainse scaoilte.
- Má bhrúiteann tú brainse ábhar ar dhearmad chuig django/django\`, scrios é. Mar shampla, má rinne tú: git push upstream feature\_antigravity\`, déan brú droim: `git push upstream:feature_antigravity`.
