submit-changes.rst 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. Contributing Changes to a Component
  3. ************************************
  4. Contributions to the Yocto Project and OpenEmbedded are very welcome.
  5. Because the system is extremely configurable and flexible, we recognize
  6. that developers will want to extend, configure or optimize it for their
  7. specific uses.
  8. .. _ref-why-mailing-lists:
  9. Contributing through mailing lists --- Why not using web-based workflows?
  10. =========================================================================
  11. Both Yocto Project and OpenEmbedded have many key components that are
  12. maintained by patches being submitted on mailing lists. We appreciate this
  13. approach does look a little old fashioned when other workflows are available
  14. through web technology such as GitHub, GitLab and others. Since we are often
  15. asked this question, we’ve decided to document the reasons for using mailing
  16. lists.
  17. One significant factor is that we value peer review. When a change is proposed
  18. to many of the core pieces of the project, it helps to have many eyes of review
  19. go over them. Whilst there is ultimately one maintainer who needs to make the
  20. final call on accepting or rejecting a patch, the review is made by many eyes
  21. and the exact people reviewing it are likely unknown to the maintainer. It is
  22. often the surprise reviewer that catches the most interesting issues!
  23. This is in contrast to the "GitHub" style workflow where either just a
  24. maintainer makes that review, or review is specifically requested from
  25. nominated people. We believe there is significant value added to the codebase
  26. by this peer review and that moving away from mailing lists would be to the
  27. detriment of our code.
  28. We also need to acknowledge that many of our developers are used to this
  29. mailing list workflow and have worked with it for years, with tools and
  30. processes built around it. Changing away from this would result in a loss
  31. of key people from the project, which would again be to its detriment.
  32. The projects are acutely aware that potential new contributors find the
  33. mailing list approach off-putting and would prefer a web-based GUI.
  34. Since we don’t believe that can work for us, the project is aiming to ensure
  35. `patchwork <https://patchwork.yoctoproject.org/>`__ is available to help track
  36. patch status and also looking at how tooling can provide more feedback to users
  37. about patch status. We are looking at improving tools such as ``patchtest`` to
  38. test user contributions before they hit the mailing lists and also at better
  39. documenting how to use such workflows since we recognise that whilst this was
  40. common knowledge a decade ago, it might not be as familiar now.
  41. Preparing Changes for Submission
  42. ================================
  43. Set up Git
  44. ----------
  45. The first thing to do is to install Git packages. Here is an example
  46. on Debian and Ubuntu::
  47. sudo apt install git-core git-email
  48. Then, you need to set a name and e-mail address that Git will
  49. use to identify your commits::
  50. git config --global user.name "Ada Lovelace"
  51. git config --global user.email "ada.lovelace@gmail.com"
  52. Clone the Git repository for the component to modify
  53. ----------------------------------------------------
  54. After identifying the component to modify as described in the
  55. ":doc:`../contributor-guide/identify-component`" section, clone the
  56. corresponding Git repository. Here is an example for OpenEmbedded-Core::
  57. git clone https://git.openembedded.org/openembedded-core
  58. cd openembedded-core
  59. Create a new branch
  60. -------------------
  61. Then, create a new branch in your local Git repository
  62. for your changes, starting from the reference branch in the upstream
  63. repository (often called ``master``)::
  64. $ git checkout <ref-branch>
  65. $ git checkout -b my-changes
  66. If you have completely unrelated sets of changes to submit, you should even
  67. create one branch for each set.
  68. Implement and commit changes
  69. ----------------------------
  70. In each branch, you should group your changes into small, controlled and
  71. isolated ones. Keeping changes small and isolated aids review, makes
  72. merging/rebasing easier and keeps the change history clean should anyone need
  73. to refer to it in future.
  74. To this purpose, you should create *one Git commit per change*,
  75. corresponding to each of the patches you will eventually submit.
  76. See `further guidance <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#separate-your-changes>`__
  77. in the Linux kernel documentation if needed.
  78. For example, when you intend to add multiple new recipes, each recipe
  79. should be added in a separate commit. For upgrades to existing recipes,
  80. the previous version should usually be deleted as part of the same commit
  81. to add the upgraded version.
  82. #. *Stage Your Changes:* Stage your changes by using the ``git add``
  83. command on each file you modified. If you want to stage all the
  84. files you modified, you can even use the ``git add -A`` command.
  85. #. *Commit Your Changes:* This is when you can create separate commits. For
  86. each commit to create, use the ``git commit -s`` command with the files
  87. or directories you want to include in the commit::
  88. $ git commit -s file1 file2 dir1 dir2 ...
  89. To include **a**\ ll staged files::
  90. $ git commit -sa
  91. - The ``-s`` option of ``git commit`` adds a "Signed-off-by:" line
  92. to your commit message. There is the same requirement for contributing
  93. to the Linux kernel. Adding such a line signifies that you, the
  94. submitter, have agreed to the `Developer's Certificate of Origin 1.1
  95. <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin>`__
  96. as follows:
  97. .. code-block:: none
  98. Developer's Certificate of Origin 1.1
  99. By making a contribution to this project, I certify that:
  100. (a) The contribution was created in whole or in part by me and I
  101. have the right to submit it under the open source license
  102. indicated in the file; or
  103. (b) The contribution is based upon previous work that, to the best
  104. of my knowledge, is covered under an appropriate open source
  105. license and I have the right under that license to submit that
  106. work with modifications, whether created in whole or in part
  107. by me, under the same open source license (unless I am
  108. permitted to submit under a different license), as indicated
  109. in the file; or
  110. (c) The contribution was provided directly to me by some other
  111. person who certified (a), (b) or (c) and I have not modified
  112. it.
  113. (d) I understand and agree that this project and the contribution
  114. are public and that a record of the contribution (including all
  115. personal information I submit with it, including my sign-off) is
  116. maintained indefinitely and may be redistributed consistent with
  117. this project or the open source license(s) involved.
  118. - Provide a single-line summary of the change and, if more
  119. explanation is needed, provide more detail in the body of the
  120. commit. This summary is typically viewable in the "shortlist" of
  121. changes. Thus, providing something short and descriptive that
  122. gives the reader a summary of the change is useful when viewing a
  123. list of many commits. You should prefix this short description
  124. with the recipe name (if changing a recipe), or else with the
  125. short form path to the file being changed.
  126. .. note::
  127. To find a suitable prefix for the commit summary, a good idea
  128. is to look for prefixes used in previous commits touching the
  129. same files or directories::
  130. git log --oneline <paths>
  131. - For the body of the commit message, provide detailed information
  132. that describes what you changed, why you made the change, and the
  133. approach you used. It might also be helpful if you mention how you
  134. tested the change. Provide as much detail as you can in the body
  135. of the commit message.
  136. .. note::
  137. If the single line summary is enough to describe a simple
  138. change, the body of the commit message can be left empty.
  139. - If the change addresses a specific bug or issue that is associated
  140. with a bug-tracking ID, include a reference to that ID in your
  141. detailed description. For example, the Yocto Project uses a
  142. specific convention for bug references --- any commit that addresses
  143. a specific bug should use the following form for the detailed
  144. description. Be sure to use the actual bug-tracking ID from
  145. Bugzilla for bug-id::
  146. Fixes [YOCTO #bug-id]
  147. detailed description of change
  148. #. *Crediting contributors:* By using the ``git commit --amend`` command,
  149. you can add some tags to the commit description to credit other contributors
  150. to the change:
  151. - ``Reported-by``: name and email of a person reporting a bug
  152. that your commit is trying to fix. This is a good practice
  153. to encourage people to go on reporting bugs and let them
  154. know that their reports are taken into account.
  155. - ``Suggested-by``: name and email of a person to credit for the
  156. idea of making the change.
  157. - ``Tested-by``, ``Reviewed-by``: name and email for people having
  158. tested your changes or reviewed their code. These fields are
  159. usually added by the maintainer accepting a patch, or by
  160. yourself if you submitted your patches to early reviewers,
  161. or are submitting an unmodified patch again as part of a
  162. new iteration of your patch series.
  163. - ``CC:`` Name and email of people you want to send a copy
  164. of your changes to. This field will be used by ``git send-email``.
  165. See `more guidance about using such tags
  166. <https://www.kernel.org/doc/html/latest/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes>`__
  167. in the Linux kernel documentation.
  168. Test your changes
  169. -----------------
  170. For each contributions you make, you should test your changes as well.
  171. For this the Yocto Project offers several types of tests. Those tests cover
  172. different areas and it depends on your changes which are feasible. For example run:
  173. - For changes that affect the build environment:
  174. - ``bitbake-selftest``: for changes within BitBake
  175. - ``oe-selftest``: to test combinations of BitBake runs
  176. - ``oe-build-perf-test``: to test the performance of common build scenarios
  177. - For changes in a recipe:
  178. - ``ptest``: run package specific tests, if they exist
  179. - ``testimage``: build an image, boot it and run testcases on it
  180. - If applicable, ensure also the ``native`` and ``nativesdk`` variants builds
  181. - For changes relating to the SDK:
  182. - ``testsdk``: to build, install and run tests against a SDK
  183. - ``testsdk_ext``: to build, install and run tests against an extended SDK
  184. Note that this list just gives suggestions and is not exhaustive. More details can
  185. be found here: :ref:`test-manual/intro:Yocto Project Tests --- Types of Testing Overview`.
  186. Creating Patches
  187. ================
  188. Here is the general procedure on how to create patches to be sent through email:
  189. #. *Describe the Changes in your Branch:* If you have more than one commit
  190. in your branch, it's recommended to provide a cover letter describing
  191. the series of patches you are about to send.
  192. For this purpose, a good solution is to store the cover letter contents
  193. in the branch itself::
  194. git branch --edit-description
  195. This will open a text editor to fill in the description for your
  196. changes. This description can be updated when necessary and will
  197. be used by Git to create the cover letter together with the patches.
  198. It is recommended to start this description with a title line which
  199. will serve a the subject line for the cover letter.
  200. #. *Generate Patches for your Branch:* The ``git format-patch`` command will
  201. generate patch files for each of the commits in your branch. You need
  202. to pass the reference branch your branch starts from.
  203. If you branch didn't need a description in the previous step::
  204. $ git format-patch <ref-branch>
  205. If you filled a description for your branch, you will want to generate
  206. a cover letter too::
  207. $ git format-patch --cover-letter --cover-from-description=auto <ref-branch>
  208. After the command is run, the current directory contains numbered
  209. ``.patch`` files for the commits in your branch. If you have a cover
  210. letter, it will be in the ``0000-cover-letter.patch``.
  211. .. note::
  212. The ``--cover-from-description=auto`` option makes ``git format-patch``
  213. use the first paragraph of the branch description as the cover
  214. letter title. Another possibility, which is easier to remember, is to pass
  215. only the ``--cover-letter`` option, but you will have to edit the
  216. subject line manually every time you generate the patches.
  217. See the `git format-patch manual page <https://git-scm.com/docs/git-format-patch>`__
  218. for details.
  219. #. *Review each of the Patch Files:* This final review of the patches
  220. before sending them often allows to view your changes from a different
  221. perspective and discover defects such as typos, spacing issues or lines
  222. or even files that you didn't intend to modify. This review should
  223. include the cover letter patch too.
  224. If necessary, rework your commits as described in
  225. ":ref:`contributor-guide/submit-changes:taking patch review into account`".
  226. Validating Patches with Patchtest
  227. =================================
  228. ``patchtest`` is available in ``openembedded-core`` as a tool for making
  229. sure that your patches are well-formatted and contain important info for
  230. maintenance purposes, such as ``Signed-off-by`` and ``Upstream-Status``
  231. tags. Note that no functional testing of the changes will be performed by ``patchtest``.
  232. Currently, it only supports testing patches for ``openembedded-core`` branches.
  233. To setup, perform the following::
  234. pip install -r meta/lib/patchtest/requirements.txt
  235. source oe-init-build-env
  236. bitbake-layers add-layer ../meta-selftest
  237. Once these steps are complete and you have generated your patch files,
  238. you can run ``patchtest`` like so::
  239. patchtest --patch <patch_name>
  240. Alternatively, if you want ``patchtest`` to iterate over and test
  241. multiple patches stored in a directory, you can use::
  242. patchtest --directory <directory_name>
  243. By default, ``patchtest`` uses its own modules' file paths to determine what
  244. repository and test suite to check patches against. If you wish to test
  245. patches against a repository other than ``openembedded-core`` and/or use
  246. a different set of tests, you can use the ``--repodir`` and ``--testdir``
  247. flags::
  248. patchtest --patch <patch_name> --repodir <path/to/repo> --testdir <path/to/testdir>
  249. Finally, note that ``patchtest`` is designed to test patches in a standalone
  250. way, so if your patches are meant to apply on top of changes made by
  251. previous patches in a series, it is possible that ``patchtest`` will report
  252. false failures regarding the "merge on head" test.
  253. Using ``patchtest`` in this manner provides a final check for the overall
  254. quality of your changes before they are submitted for review by the
  255. maintainers.
  256. Sending the Patches via Email
  257. =============================
  258. Using Git to Send Patches
  259. -------------------------
  260. To submit patches through email, it is very important that you send them
  261. without any whitespace or HTML formatting that either you or your mailer
  262. introduces. The maintainer that receives your patches needs to be able
  263. to save and apply them directly from your emails, using the ``git am``
  264. command.
  265. Using the ``git send-email`` command is the only error-proof way of sending
  266. your patches using email since there is no risk of compromising whitespace
  267. in the body of the message, which can occur when you use your own mail
  268. client. It will also properly include your patches as *inline attachments*,
  269. which is not easy to do with standard e-mail clients without breaking lines.
  270. If you used your regular e-mail client and shared your patches as regular
  271. attachments, reviewers wouldn't be able to quote specific sections of your
  272. changes and make comments about them.
  273. Setting up Git to Send Email
  274. ----------------------------
  275. The ``git send-email`` command can send email by using a local or remote
  276. Mail Transport Agent (MTA) such as ``msmtp``, ``sendmail``, or
  277. through a direct SMTP configuration in your Git ``~/.gitconfig`` file.
  278. Here are the settings for letting ``git send-email`` send e-mail through your
  279. regular STMP server, using a Google Mail account as an example::
  280. git config --global sendemail.smtpserver smtp.gmail.com
  281. git config --global sendemail.smtpserverport 587
  282. git config --global sendemail.smtpencryption tls
  283. git config --global sendemail.smtpuser ada.lovelace@gmail.com
  284. git config --global sendemail.smtppass = XXXXXXXX
  285. These settings will appear in the ``.gitconfig`` file in your home directory.
  286. If you neither can use a local MTA nor SMTP, make sure you use an email client
  287. that does not touch the message (turning spaces in tabs, wrapping lines, etc.).
  288. A good mail client to do so is Pine (or Alpine) or Mutt. For more
  289. information about suitable clients, see `Email clients info for Linux
  290. <https://www.kernel.org/doc/html/latest/process/email-clients.html>`__
  291. in the Linux kernel sources.
  292. If you use such clients, just include the patch in the body of your email.
  293. Finding a Suitable Mailing List
  294. -------------------------------
  295. You should send patches to the appropriate mailing list so that they can be
  296. reviewed by the right contributors and merged by the appropriate maintainer.
  297. The specific mailing list you need to use depends on the location of the code
  298. you are changing.
  299. If people have concerns with any of the patches, they will usually voice
  300. their concern over the mailing list. If patches do not receive any negative
  301. reviews, the maintainer of the affected layer typically takes them, tests them,
  302. and then based on successful testing, merges them.
  303. In general, each component (e.g. layer) should have a ``README`` file
  304. that indicates where to send the changes and which process to follow.
  305. The "poky" repository, which is the Yocto Project's reference build
  306. environment, is a hybrid repository that contains several individual
  307. pieces (e.g. BitBake, Metadata, documentation, and so forth) built using
  308. the combo-layer tool. The upstream location used for submitting changes
  309. varies by component:
  310. - *Core Metadata:* Send your patches to the
  311. :oe_lists:`openembedded-core </g/openembedded-core>`
  312. mailing list. For example, a change to anything under the ``meta`` or
  313. ``scripts`` directories should be sent to this mailing list.
  314. - *BitBake:* For changes to BitBake (i.e. anything under the
  315. ``bitbake`` directory), send your patches to the
  316. :oe_lists:`bitbake-devel </g/bitbake-devel>`
  317. mailing list.
  318. - *meta-poky* and *meta-yocto-bsp* trees: These trees contain Metadata. Use the
  319. :yocto_lists:`poky </g/poky>` mailing list.
  320. - *Documentation*: For changes to the Yocto Project documentation, use the
  321. :yocto_lists:`docs </g/docs>` mailing list.
  322. For changes to other layers and tools hosted in the Yocto Project source
  323. repositories (i.e. :yocto_git:`git.yoctoproject.org <>`), use the
  324. :yocto_lists:`yocto </g/yocto/>` general mailing list.
  325. For changes to other layers hosted in the OpenEmbedded source
  326. repositories (i.e. :oe_git:`git.openembedded.org <>`), use
  327. the :oe_lists:`openembedded-devel </g/openembedded-devel>`
  328. mailing list, unless specified otherwise in the layer's ``README`` file.
  329. If you intend to submit a new recipe that neither fits into the core Metadata,
  330. nor into :oe_git:`meta-openembedded </meta-openembedded/>`, you should
  331. look for a suitable layer in https://layers.openembedded.org. If similar
  332. recipes can be expected, you may consider :ref:`dev-manual/layers:creating your own layer`.
  333. If in doubt, please ask on the :yocto_lists:`yocto </g/yocto/>` general mailing list
  334. or on the :oe_lists:`openembedded-devel </g/openembedded-devel>` mailing list.
  335. Subscribing to the Mailing List
  336. -------------------------------
  337. After identifying the right mailing list to use, you will have to subscribe to
  338. it if you haven't done it yet.
  339. If you attempt to send patches to a list you haven't subscribed to, your email
  340. will be returned as undelivered.
  341. However, if you don't want to be receive all the messages sent to a mailing list,
  342. you can set your subscription to "no email". You will still be a subscriber able
  343. to send messages, but you won't receive any e-mail. If people reply to your message,
  344. their e-mail clients will default to including your email address in the
  345. conversation anyway.
  346. Anyway, you'll also be able to access the new messages on mailing list archives,
  347. either through a web browser, or for the lists archived on https://lore.kernel.org,
  348. through an individual newsgroup feed or a git repository.
  349. Sending Patches via Email
  350. -------------------------
  351. At this stage, you are ready to send your patches via email. Here's the
  352. typical usage of ``git send-email``::
  353. git send-email --to <mailing-list-address> *.patch
  354. Then, review each subject line and list of recipients carefully, and then
  355. and then allow the command to send each message.
  356. You will see that ``git send-email`` will automatically copy the people listed
  357. in any commit tags such as ``Signed-off-by`` or ``Reported-by``.
  358. In case you are sending patches for :oe_git:`meta-openembedded </meta-openembedded/>`
  359. or any layer other than :oe_git:`openembedded-core </openembedded-core/>`,
  360. please add the appropriate prefix so that it is clear which layer the patch is intended
  361. to be applied to::
  362. git format-patch --subject-prefix="meta-oe][PATCH" ...
  363. .. note::
  364. It is actually possible to send patches without generating them
  365. first. However, make sure you have reviewed your changes carefully
  366. because ``git send-email`` will just show you the title lines of
  367. each patch.
  368. Here's a command you can use if you just have one patch in your
  369. branch::
  370. git send-email --to <mailing-list-address> -1
  371. If you have multiple patches and a cover letter, you can send
  372. patches for all the commits between the reference branch
  373. and the tip of your branch::
  374. git send-email --cover-letter --cover-from-description=auto --to <mailing-list-address> -M <ref-branch>
  375. See the `git send-email manual page <https://git-scm.com/docs/git-send-email>`__
  376. for details.
  377. Troubleshooting Email Issues
  378. ----------------------------
  379. Fixing your From identity
  380. ~~~~~~~~~~~~~~~~~~~~~~~~~
  381. We have a frequent issue with contributors whose patches are received through
  382. a ``From`` field which doesn't match the ``Signed-off-by`` information. Here is
  383. a typical example for people sending from a domain name with :wikipedia:`DMARC`::
  384. From: "Linus Torvalds via lists.openembedded.org <linus.torvalds=kernel.org@lists.openembedded.org>"
  385. This ``From`` field is used by ``git am`` to recreate commits with the right
  386. author name. The following will ensure that your e-mails have an additional
  387. ``From`` field at the beginning of the Email body, and therefore that
  388. maintainers accepting your patches don't have to fix commit author information
  389. manually::
  390. git config --global sendemail.from "linus.torvalds@kernel.org"
  391. The ``sendemail.from`` should match your ``user.email`` setting,
  392. which appears in the ``Signed-off-by`` line of your commits.
  393. Streamlining git send-email usage
  394. ---------------------------------
  395. If you want to save time and not be forced to remember the right options to use
  396. with ``git send-email``, you can use Git configuration settings.
  397. - To set the right mailing list address for a given repository::
  398. git config --local sendemail.to openembedded-devel@lists.openembedded.org
  399. - If the mailing list requires a subject prefix for the layer
  400. (this only works when the repository only contains one layer)::
  401. git config --local format.subjectprefix "meta-something][PATCH"
  402. Using Scripts to Push a Change Upstream and Request a Pull
  403. ==========================================================
  404. For larger patch series it is preferable to send a pull request which not
  405. only includes the patch but also a pointer to a branch that can be pulled
  406. from. This involves making a local branch for your changes, pushing this
  407. branch to an accessible repository and then using the ``create-pull-request``
  408. and ``send-pull-request`` scripts from openembedded-core to create and send a
  409. patch series with a link to the branch for review.
  410. Follow this procedure to push a change to an upstream "contrib" Git
  411. repository once the steps in
  412. ":ref:`contributor-guide/submit-changes:preparing changes for submission`"
  413. have been followed:
  414. .. note::
  415. You can find general Git information on how to push a change upstream
  416. in the
  417. `Git Community Book <https://git-scm.com/book/en/v2/Distributed-Git-Distributed-Workflows>`__.
  418. #. *Request Push Access to an "Upstream" Contrib Repository:* Send an email to
  419. ``helpdesk@yoctoproject.org``:
  420. - Attach your SSH public key which usually named ``id_rsa.pub.``.
  421. If you don't have one generate it by running ``ssh-keygen -t rsa -b 4096 -C "your_email@example.com"``.
  422. - List the repositories you're planning to contribute to.
  423. - Include your preferred branch prefix for ``-contrib`` repositories.
  424. #. *Push Your Commits to the "Contrib" Upstream:* Push your
  425. changes to that repository::
  426. $ git push upstream_remote_repo local_branch_name
  427. For example, suppose you have permissions to push
  428. into the upstream ``meta-intel-contrib`` repository and you are
  429. working in a local branch named `your_name`\ ``/README``. The following
  430. command pushes your local commits to the ``meta-intel-contrib``
  431. upstream repository and puts the commit in a branch named
  432. `your_name`\ ``/README``::
  433. $ git push meta-intel-contrib your_name/README
  434. #. *Determine Who to Notify:* Determine the maintainer or the mailing
  435. list that you need to notify for the change.
  436. Before submitting any change, you need to be sure who the maintainer
  437. is or what mailing list that you need to notify. Use either these
  438. methods to find out:
  439. - *Maintenance File:* Examine the ``maintainers.inc`` file, which is
  440. located in the :term:`Source Directory` at
  441. ``meta/conf/distro/include``, to see who is responsible for code.
  442. - *Search by File:* Using :ref:`overview-manual/development-environment:git`, you can
  443. enter the following command to bring up a short list of all
  444. commits against a specific file::
  445. git shortlog -- filename
  446. Just provide the name of the file for which you are interested. The
  447. information returned is not ordered by history but does include a
  448. list of everyone who has committed grouped by name. From the list,
  449. you can see who is responsible for the bulk of the changes against
  450. the file.
  451. - *Find the Mailing List to Use:* See the
  452. ":ref:`contributor-guide/submit-changes:finding a suitable mailing list`"
  453. section above.
  454. #. *Make a Pull Request:* Notify the maintainer or the mailing list that
  455. you have pushed a change by making a pull request.
  456. The Yocto Project provides two scripts that conveniently let you
  457. generate and send pull requests to the Yocto Project. These scripts
  458. are ``create-pull-request`` and ``send-pull-request``. You can find
  459. these scripts in the ``scripts`` directory within the
  460. :term:`Source Directory` (e.g.
  461. ``poky/scripts``).
  462. Using these scripts correctly formats the requests without
  463. introducing any whitespace or HTML formatting. The maintainer that
  464. receives your patches either directly or through the mailing list
  465. needs to be able to save and apply them directly from your emails.
  466. Using these scripts is the preferred method for sending patches.
  467. First, create the pull request. For example, the following command
  468. runs the script, specifies the upstream repository in the contrib
  469. directory into which you pushed the change, and provides a subject
  470. line in the created patch files::
  471. $ poky/scripts/create-pull-request -u meta-intel-contrib -s "Updated Manual Section Reference in README"
  472. Running this script forms ``*.patch`` files in a folder named
  473. ``pull-``\ `PID` in the current directory. One of the patch files is a
  474. cover letter.
  475. Before running the ``send-pull-request`` script, you must edit the
  476. cover letter patch to insert information about your change. After
  477. editing the cover letter, send the pull request. For example, the
  478. following command runs the script and specifies the patch directory
  479. and email address. In this example, the email address is a mailing
  480. list::
  481. $ poky/scripts/send-pull-request -p ~/meta-intel/pull-10565 -t meta-intel@lists.yoctoproject.org
  482. You need to follow the prompts as the script is interactive.
  483. .. note::
  484. For help on using these scripts, simply provide the ``-h``
  485. argument as follows::
  486. $ poky/scripts/create-pull-request -h
  487. $ poky/scripts/send-pull-request -h
  488. Submitting Changes to Stable Release Branches
  489. =============================================
  490. The process for proposing changes to a Yocto Project stable branch differs
  491. from the steps described above. Changes to a stable branch must address
  492. identified bugs or CVEs and should be made carefully in order to avoid the
  493. risk of introducing new bugs or breaking backwards compatibility. Typically
  494. bug fixes must already be accepted into the master branch before they can be
  495. backported to a stable branch unless the bug in question does not affect the
  496. master branch or the fix on the master branch is unsuitable for backporting.
  497. The list of stable branches along with the status and maintainer for each
  498. branch can be obtained from the
  499. :yocto_wiki:`Releases wiki page </Releases>`.
  500. .. note::
  501. Changes will not typically be accepted for branches which are marked as
  502. End-Of-Life (EOL).
  503. With this in mind, the steps to submit a change for a stable branch are as
  504. follows:
  505. #. *Identify the bug or CVE to be fixed:* This information should be
  506. collected so that it can be included in your submission.
  507. See :ref:`dev-manual/vulnerabilities:checking for vulnerabilities`
  508. for details about CVE tracking.
  509. #. *Check if the fix is already present in the master branch:* This will
  510. result in the most straightforward path into the stable branch for the
  511. fix.
  512. #. *If the fix is present in the master branch --- submit a backport request
  513. by email:* You should send an email to the relevant stable branch
  514. maintainer and the mailing list with details of the bug or CVE to be
  515. fixed, the commit hash on the master branch that fixes the issue and
  516. the stable branches which you would like this fix to be backported to.
  517. #. *If the fix is not present in the master branch --- submit the fix to the
  518. master branch first:* This will ensure that the fix passes through the
  519. project's usual patch review and test processes before being accepted.
  520. It will also ensure that bugs are not left unresolved in the master
  521. branch itself. Once the fix is accepted in the master branch a backport
  522. request can be submitted as above.
  523. #. *If the fix is unsuitable for the master branch --- submit a patch
  524. directly for the stable branch:* This method should be considered as a
  525. last resort. It is typically necessary when the master branch is using
  526. a newer version of the software which includes an upstream fix for the
  527. issue or when the issue has been fixed on the master branch in a way
  528. that introduces backwards incompatible changes. In this case follow the
  529. steps in ":ref:`contributor-guide/submit-changes:preparing changes for submission`"
  530. and in the following sections but modify the subject header of your patch
  531. email to include the name of the stable branch which you are
  532. targetting. This can be done using the ``--subject-prefix`` argument to
  533. ``git format-patch``, for example to submit a patch to the
  534. "&DISTRO_NAME_NO_CAP_MINUS_ONE;" branch use::
  535. git format-patch --subject-prefix='&DISTRO_NAME_NO_CAP_MINUS_ONE;][PATCH' ...
  536. Taking Patch Review into Account
  537. ================================
  538. You may get feedback on your submitted patches from other community members
  539. or from the automated patchtest service. If issues are identified in your
  540. patches then it is usually necessary to address these before the patches are
  541. accepted into the project. In this case you should your commits according
  542. to the feedback and submit an updated version to the relevant mailing list.
  543. In any case, never fix reported issues by fixing them in new commits
  544. on the tip of your branch. Always come up with a new series of commits
  545. without the reported issues.
  546. .. note::
  547. It is a good idea to send a copy to the reviewers who provided feedback
  548. to the previous version of the patch. You can make sure this happens
  549. by adding a ``CC`` tag to the commit description::
  550. CC: William Shakespeare <bill@yoctoproject.org>
  551. A single patch can be amended using ``git commit --amend``, and multiple
  552. patches can be easily reworked and reordered through an interactive Git rebase::
  553. git rebase -i <ref-branch>
  554. See `this tutorial <https://hackernoon.com/beginners-guide-to-interactive-rebasing-346a3f9c3a6d>`__
  555. for practical guidance about using Git interactive rebasing.
  556. You should also modify the ``[PATCH]`` tag in the email subject line when
  557. sending the revised patch to mark the new iteration as ``[PATCH v2]``,
  558. ``[PATCH v3]``, etc as appropriate. This can be done by passing the ``-v``
  559. argument to ``git format-patch`` with a version number::
  560. git format-patch -v2 <ref-branch>
  561. Lastly please ensure that you also test your revised changes. In particular
  562. please don't just edit the patch file written out by ``git format-patch`` and
  563. resend it.
  564. Tracking the Status of Patches
  565. ==============================
  566. The Yocto Project uses a `Patchwork instance <https://patchwork.yoctoproject.org/>`__
  567. to track the status of patches submitted to the various mailing lists and to
  568. support automated patch testing. Each submitted patch is checked for common
  569. mistakes and deviations from the expected patch format and submitters are
  570. notified by ``patchtest`` if such mistakes are found. This process helps to
  571. reduce the burden of patch review on maintainers.
  572. .. note::
  573. This system is imperfect and changes can sometimes get lost in the flow.
  574. Asking about the status of a patch or change is reasonable if the change
  575. has been idle for a while with no feedback.
  576. If your patches have not had any feedback in a few days, they may have already
  577. been merged. You can run ``git pull`` branch to check this. Note that many if
  578. not most layer maintainers do not send out acknowledgement emails when they
  579. accept patches. Alternatively, if there is no response or merge after a few days
  580. the patch may have been missed or the appropriate reviewers may not currently be
  581. around. It is then perfectly fine to reply to it yourself with a reminder asking
  582. for feedback.
  583. .. note::
  584. Patch reviews for feature and recipe upgrade patches are likely be delayed
  585. during a feature freeze because these types of patches aren't merged during
  586. at that time --- you may have to wait until after the freeze is lifted.
  587. Maintainers also commonly use ``-next`` branches to test submissions prior to
  588. merging patches. Thus, you can get an idea of the status of a patch based on
  589. whether the patch has been merged into one of these branches. The commonly
  590. used testing branches for OpenEmbedded-Core are as follows:
  591. - *openembedded-core "master-next" branch:* This branch is part of the
  592. :oe_git:`openembedded-core </openembedded-core/>` repository and contains
  593. proposed changes to the core metadata.
  594. - *poky "master-next" branch:* This branch is part of the
  595. :yocto_git:`poky </poky/>` repository and combines proposed
  596. changes to BitBake, the core metadata and the poky distro.
  597. Similarly, stable branches maintained by the project may have corresponding
  598. ``-next`` branches which collect proposed changes. For example,
  599. ``&DISTRO_NAME_NO_CAP;-next`` and ``&DISTRO_NAME_NO_CAP_MINUS_ONE;-next``
  600. branches in both the "openembdedded-core" and "poky" repositories.
  601. Other layers may have similar testing branches but there is no formal
  602. requirement or standard for these so please check the documentation for the
  603. layers you are contributing to.