1
- ===================================
2
- Writing your first patch for Django
3
- ===================================
1
+ ==========================================
2
+ Writing your first contribution for Django
3
+ ==========================================
4
4
5
5
Introduction
6
6
============
@@ -52,16 +52,16 @@ __ https://web.libera.chat/#django-dev
52
52
What does this tutorial cover?
53
53
------------------------------
54
54
55
- We'll be walking you through contributing a patch to Django for the first time.
55
+ We'll be walking you through contributing to Django for the first time.
56
56
By the end of this tutorial, you should have a basic understanding of both the
57
57
tools and the processes involved. Specifically, we'll be covering the following:
58
58
59
59
* Installing Git.
60
60
* Downloading a copy of Django's development version.
61
61
* Running Django's test suite.
62
- * Writing a test for your patch .
63
- * Writing the code for your patch .
64
- * Testing your patch .
62
+ * Writing a test for your changes .
63
+ * Writing the code for your changes .
64
+ * Testing your changes .
65
65
* Submitting a pull request.
66
66
* Where to look for more information.
67
67
@@ -91,7 +91,7 @@ Installing Git
91
91
==============
92
92
93
93
For this tutorial, you'll need Git installed to download the current
94
- development version of Django and to generate patch files for the changes you
94
+ development version of Django and to generate a branch for the changes you
95
95
make.
96
96
97
97
To check whether or not you have Git installed, enter ``git`` into the command
@@ -178,7 +178,7 @@ Go ahead and install the previously cloned copy of Django:
178
178
179
179
The installed version of Django is now pointing at your local copy by installing
180
180
in editable mode. You will immediately see any changes you make to it, which is
181
- of great help when writing your first patch .
181
+ of great help when writing your first contribution .
182
182
183
183
Creating projects with a local copy of Django
184
184
---------------------------------------------
@@ -188,8 +188,8 @@ have to create a new virtual environment, :ref:`install the previously cloned
188
188
local copy of Django in editable mode <intro-contributing-install-local-copy>`,
189
189
and create a new Django project outside of your local copy of Django. You will
190
190
immediately see any changes you make to Django in your new project, which is
191
- of great help when writing your first patch , especially if testing any changes
192
- to the UI.
191
+ of great help when writing your first contribution , especially if testing
192
+ any changes to the UI.
193
193
194
194
You can follow the :doc:`tutorial</intro/tutorial01>` for help in creating a
195
195
Django project.
@@ -279,8 +279,8 @@ imaginary details:
279
279
280
280
We'll now implement this feature and associated tests.
281
281
282
- Creating a branch for your patch
283
- ================================
282
+ Creating a branch
283
+ =================
284
284
285
285
Before making any changes, create a new branch for the ticket:
286
286
@@ -295,19 +295,19 @@ won't affect the main copy of the code that we cloned earlier.
295
295
Writing some tests for your ticket
296
296
==================================
297
297
298
- In most cases, for a patch to be accepted into Django it has to include tests.
299
- For bug fix patches , this means writing a regression test to ensure that the
300
- bug is never reintroduced into Django later on. A regression test should be
301
- written in such a way that it will fail while the bug still exists and pass
302
- once the bug has been fixed. For patches containing new features, you'll need
303
- to include tests which ensure that the new features are working correctly.
304
- They too should fail when the new feature is not present, and then pass once it
305
- has been implemented.
298
+ In most cases, for a contribution to be accepted into Django it has to include
299
+ tests. For bug fix contributions , this means writing a regression test to
300
+ ensure that the bug is never reintroduced into Django later on. A regression
301
+ test should be written in such a way that it will fail while the bug still
302
+ exists and pass once the bug has been fixed. For contributions containing new
303
+ features, you'll need to include tests which ensure that the new features are
304
+ working correctly. They too should fail when the new feature is not present,
305
+ and then pass once it has been implemented.
306
306
307
307
A good way to do this is to write your new tests first, before making any
308
308
changes to the code. This style of development is called
309
309
`test-driven development`__ and can be applied to both entire projects and
310
- single patches . After writing your tests, you then run them to make sure that
310
+ single changes . After writing your tests, you then run them to make sure that
311
311
they do indeed fail (since you haven't fixed that bug or added that feature
312
312
yet). If your new tests don't fail, you'll need to fix them so that they do.
313
313
After all, a regression test that passes regardless of whether a bug is present
@@ -398,7 +398,7 @@ function to the correct file.
398
398
Running Django's test suite for the second time
399
399
===============================================
400
400
401
- Once you've verified that your patch and your test are working correctly, it's
401
+ Once you've verified that your changes and test are working correctly, it's
402
402
a good idea to run the entire Django test suite to verify that your change
403
403
hasn't introduced any bugs into other areas of Django. While successfully
404
404
passing the entire test suite doesn't guarantee your code is bug free, it does
@@ -450,7 +450,7 @@ preview the HTML that will be generated.
450
450
Previewing your changes
451
451
=======================
452
452
453
- Now it's time to go through all the changes made in our patch . To stage all the
453
+ Now it's time to review the changes made in the branch . To stage all the
454
454
changes ready for commit, run:
455
455
456
456
.. console::
@@ -528,12 +528,11 @@ Use the arrow keys to move up and down.
528
528
+ def test_make_toast(self):
529
529
+ self.assertEqual(make_toast(), 'toast')
530
530
531
- When you're done previewing the patch, hit the ``q`` key to return to the
532
- command line. If the patch's content looked okay, it's time to commit the
533
- changes.
531
+ When you're done previewing the changes, hit the ``q`` key to return to the
532
+ command line. If the diff looked okay, it's time to commit the changes.
534
533
535
- Committing the changes in the patch
536
- ===================================
534
+ Committing the changes
535
+ ======================
537
536
538
537
To commit the changes:
539
538
@@ -551,7 +550,7 @@ message guidelines <committing-guidelines>` and write a message like:
551
550
Pushing the commit and making a pull request
552
551
============================================
553
552
554
- After committing the patch , send it to your fork on GitHub (substitute
553
+ After committing the changes , send it to your fork on GitHub (substitute
555
554
"ticket_99999" with the name of your branch if it's different):
556
555
557
556
.. console::
@@ -563,7 +562,7 @@ You can create a pull request by visiting the `Django GitHub page
563
562
recently pushed branches". Click "Compare & pull request" next to it.
564
563
565
564
Please don't do it for this tutorial, but on the next page that displays a
566
- preview of the patch , you would click "Create pull request".
565
+ preview of the changes , you would click "Create pull request".
567
566
568
567
Next steps
569
568
==========
@@ -578,14 +577,14 @@ codebase.
578
577
More information for new contributors
579
578
-------------------------------------
580
579
581
- Before you get too into writing patches for Django, there's a little more
580
+ Before you get too into contributing to Django, there's a little more
582
581
information on contributing that you should probably take a look at:
583
582
584
583
* You should make sure to read Django's documentation on
585
- :doc:`claiming tickets and submitting patches
584
+ :doc:`claiming tickets and submitting pull requests
586
585
</internals/contributing/writing-code/submitting-patches>`.
587
586
It covers Trac etiquette, how to claim tickets for yourself, expected
588
- coding style for patches , and many other important details.
587
+ coding style (both for code and docs) , and many other important details.
589
588
* First time contributors should also read Django's :doc:`documentation
590
589
for first time contributors</internals/contributing/new-contributors/>`.
591
590
It has lots of good advice for those of us who are new to helping out
@@ -600,19 +599,19 @@ Finding your first real ticket
600
599
------------------------------
601
600
602
601
Once you've looked through some of that information, you'll be ready to go out
603
- and find a ticket of your own to write a patch for . Pay special attention to
602
+ and find a ticket of your own to contribute to . Pay special attention to
604
603
tickets with the "easy pickings" criterion. These tickets are often much
605
604
simpler in nature and are great for first time contributors. Once you're
606
- familiar with contributing to Django, you can move on to writing patches for
607
- more difficult and complicated tickets.
605
+ familiar with contributing to Django, you can start working on more difficult
606
+ and complicated tickets.
608
607
609
608
If you just want to get started already (and nobody would blame you!), try
610
- taking a look at the list of `easy tickets that need patches `__ and the
611
- `easy tickets that have patches which need improvement`__. If you're familiar
609
+ taking a look at the list of `easy tickets without a branch `__ and the
610
+ `easy tickets that have branches which need improvement`__. If you're familiar
612
611
with writing tests, you can also look at the list of
613
612
`easy tickets that need tests`__. Remember to follow the guidelines about
614
613
claiming tickets that were mentioned in the link to Django's documentation on
615
- :doc:`claiming tickets and submitting patches
614
+ :doc:`claiming tickets and submitting branches
616
615
</internals/contributing/writing-code/submitting-patches>`.
617
616
618
617
__ https://code.djangoproject.com/query?status=new&status=reopened&has_patch=0&easy=1&col=id&col=summary&col=status&col=owner&col=type&col=milestone&order=priority
@@ -622,9 +621,9 @@ __ https://code.djangoproject.com/query?status=new&status=reopened&needs_tests=1
622
621
What's next after creating a pull request?
623
622
------------------------------------------
624
623
625
- After a ticket has a patch , it needs to be reviewed by a second set of eyes.
624
+ After a ticket has a branch , it needs to be reviewed by a second set of eyes.
626
625
After submitting a pull request, update the ticket metadata by setting the
627
626
flags on the ticket to say "has patch", "doesn't need tests", etc, so others
628
- can find it for review. Contributing doesn't necessarily always mean writing a
629
- patch from scratch. Reviewing existing patches is also a very helpful
627
+ can find it for review. Contributing doesn't necessarily always mean writing
628
+ code from scratch. Reviewing open pull requests is also a very helpful
630
629
contribution. See :doc:`/internals/contributing/triaging-tickets` for details.
0 commit comments