Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | .. _contribute: |
| 2 | |
| 3 | ########## |
| 4 | Contribute |
| 5 | ########## |
| 6 | Contributions to OP-TEE are managed by the OP-TEE :ref:`core_team` and anyone |
| 7 | can contribute to OP-TEE as long as it is understood that it will require a |
| 8 | `Signed-off-by` tag from the one submitting the patch(es). The Signed-off-by tag |
| 9 | is a simple line at the end of the explanation for the patch, which certifies |
| 10 | that you wrote it or otherwise have the right to pass it on as an open source |
| 11 | patch (see below). You thereby assure that you have read and are following the |
| 12 | rules stated in the ``Developer Certificate of Origin`` as stated below. |
| 13 | |
| 14 | .. _DCO: |
| 15 | |
| 16 | Developer Certificate of Origin |
| 17 | ******************************* |
| 18 | |
| 19 | .. code-block:: none |
| 20 | |
| 21 | Developer Certificate of Origin |
| 22 | Version 1.1 |
| 23 | |
| 24 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. |
| 25 | 660 York Street, Suite 102, |
| 26 | San Francisco, CA 94110 USA |
| 27 | |
| 28 | Everyone is permitted to copy and distribute verbatim copies of this |
| 29 | license document, but changing it is not allowed. |
| 30 | |
| 31 | |
| 32 | Developer's Certificate of Origin 1.1 |
| 33 | |
| 34 | By making a contribution to this project, I certify that: |
| 35 | |
| 36 | (a) The contribution was created in whole or in part by me and I |
| 37 | have the right to submit it under the open source license |
| 38 | indicated in the file; or |
| 39 | |
| 40 | (b) The contribution is based upon previous work that, to the best |
| 41 | of my knowledge, is covered under an appropriate open source |
| 42 | license and I have the right under that license to submit that |
| 43 | work with modifications, whether created in whole or in part |
| 44 | by me, under the same open source license (unless I am |
| 45 | permitted to submit under a different license), as indicated |
| 46 | in the file; or |
| 47 | |
| 48 | (c) The contribution was provided directly to me by some other |
| 49 | person who certified (a), (b) or (c) and I have not modified |
| 50 | it. |
| 51 | |
| 52 | (d) I understand and agree that this project and the contribution |
| 53 | are public and that a record of the contribution (including all |
| 54 | personal information I submit with it, including my sign-off) is |
| 55 | maintained indefinitely and may be redistributed consistent with |
| 56 | this project or the open source license(s) involved. |
| 57 | |
| 58 | We have borrowed this procedure from the Linux kernel project to improve |
| 59 | tracking of who did what, and for legal reasons. |
| 60 | |
| 61 | To sign-off a patch, just add a line in the commit message saying: |
| 62 | |
| 63 | .. code-block:: none |
| 64 | |
| 65 | Signed-off-by: Random J Developer <random@developer.example.org> |
| 66 | |
| 67 | Use your real name or on some rare cases a company email address, but we |
| 68 | disallow pseudonyms or anonymous contributions. |
| 69 | |
| 70 | GitHub |
| 71 | ****** |
| 72 | This section describes how to use GitHub for OP-TEE development and |
| 73 | contributions. |
| 74 | |
| 75 | Setting up an account |
| 76 | ===================== |
| 77 | You do not need to own a GitHub account in order to clone a repository. But if |
| 78 | you want to contribute, you need to create an account at GitHub_. Note that a |
| 79 | free plan is sufficient to collaborate. |
| 80 | |
| 81 | SSH is recommended to access your GitHub repositories securely and without |
| 82 | supplying your username and password each time you pull or push something. |
| 83 | To configure SSH for GitHub, please refer to `Connecting to GitHub with SSH`_. |
| 84 | |
| 85 | Forking |
| 86 | ======= |
| 87 | Only owners of the OP-TEE projects have write permissions to the git |
| 88 | repositories of those projects. Contributors **should fork** ``OP-TEE/*.git`` |
| 89 | and/or ``linaro-swg/*.git`` into their own account, then work on this forked |
| 90 | repository. The complete documentation about **forking** can be found at `fork a |
| 91 | repo`_. |
| 92 | |
| 93 | Creating pull requests |
| 94 | ====================== |
| 95 | When you want to submit a patch to the OP-TEE project, you are supposed to |
| 96 | create a `pull request`_ to the git where you forked your git from. How that is |
| 97 | done using GitHub is explained at the GitHub `pull request`_ page. |
| 98 | |
| 99 | Commit messages |
| 100 | =============== |
| 101 | |
| 102 | - The **subject line** should explain **what** the patch does as precisely |
| 103 | as possible. It is usually prefixed with keywords indicating which part of |
| 104 | the code is affected, but not always. Avoid lines longer than 80 |
| 105 | characters. |
| 106 | |
| 107 | - The **commit description** should give more details on **what** is |
| 108 | changed, and explain **why** it is done. Indication on how to enable and |
| 109 | use some particular feature can be useful, too. Try to limit line length |
| 110 | to 72 characters, except when pasting some error message (compiler |
| 111 | diagnostic etc.). Long lines are allowed to accommodate URLs, too |
| 112 | (preferably use URLs in a Fixes: or Link: tag). |
| 113 | |
| 114 | - The commit message **must** end with a blank line followed by some tags, |
| 115 | including your ``Signed-off-by:`` tag. By applying such a tag to your |
| 116 | commit, you are effectively declaring that your contribution follows the |
| 117 | terms stated by :ref:`DCO` (in the DCO section there is also a complete |
| 118 | example). |
| 119 | |
| 120 | - Other tags may be used, such as: |
| 121 | |
| 122 | - ``Tested-by: Test R <test@r.com>`` |
| 123 | - ``Acked-by: Acke R <acke@r.com>`` |
| 124 | - ``Suggested-by: Suggeste R <suggeste@r.com>`` |
| 125 | - ``Reported-by: Reporte R <reporte@r.com>`` |
| 126 | |
| 127 | - When citing a previous commit, whether it is in the text body or in a |
| 128 | Fixes: tag, always use the format shown above (12 hexadecimal digits |
| 129 | prefix of the commit ``SHA1``, followed by the commit subject in double |
| 130 | quotes and parentheses). |
| 131 | |
| 132 | Review feedback |
| 133 | =============== |
| 134 | It is very likely that you will get review comments from other OP-TEE users |
| 135 | asking you to fix certain things etc. When fixing review comments, do: |
| 136 | |
| 137 | - **Add** `fixup` patches on **top** of your existing branch. **Do not** |
| 138 | squash and force push while fixing review comments. |
| 139 | |
| 140 | - When all comments have been addressed, just write a simple messages in the |
| 141 | comments field saying something like "All comments have been addressed". |
| 142 | By doing so you will notify the maintainers that the fix might be ready |
| 143 | for review again. |
| 144 | |
| 145 | Finalizing your contribution |
| 146 | ============================ |
| 147 | Once you and reviewers have agreed on the patch set, which is when all the |
| 148 | people who have commented on the pull request have given their ``Acked-by:`` or |
| 149 | ``Reviewed-by:``, you need to consolidate your commits: |
| 150 | |
| 151 | Use ``git rebase -i`` to squash the fixup commits (if any) into the initial |
| 152 | ones. For instance, suppose the ``git log --oneline`` for you contribution looks |
| 153 | as follows when the review process ends: |
| 154 | |
| 155 | .. code-block:: none |
| 156 | |
| 157 | <sha1-commit4> [Review] Do something |
| 158 | <sha1-commit3> [Review] Do something |
| 159 | <sha1-commit2> Do something else |
| 160 | <sha1-commit1> Do something |
| 161 | |
| 162 | Then you would do: |
| 163 | |
| 164 | .. code-block:: bash |
| 165 | |
| 166 | $ git rebase -i <sha1-commit1>^ |
| 167 | |
| 168 | Edit the commit script so it looks like so: |
| 169 | |
| 170 | .. code-block:: none |
| 171 | |
| 172 | pick <sha1-commit1> Do something |
| 173 | squash <sha1-commit3> [Review] Do something |
| 174 | squash <sha1-commit4> [Review] Do something |
| 175 | pick <sha1-commit2> Do something else |
| 176 | |
| 177 | Add the proper tags (``Acked-by: ...``, ``Reviewed-by: ...``, ``Tested-by: |
| 178 | ...``) to the commit message(s) for each and every commit as provided by the |
| 179 | people who reviewed and/or tested the patches. |
| 180 | |
| 181 | .. hint:: |
| 182 | |
| 183 | ``git commit --fixup=<sha1-of-commit-to-fix>`` and later on ``git rebase -i |
| 184 | --autosquash <sha1-of-first-commit-in-patch-serie>^1`` is pretty convenient |
| 185 | to use when adding review patches and doing the final squash operation. |
| 186 | |
| 187 | Once ``rebase -i`` is done, you need to force-push (``-f``) to your GitHub |
| 188 | branch in order to update the pull request page. |
| 189 | |
| 190 | .. code-block:: bash |
| 191 | |
| 192 | $ git push -f <my-remote> <my-branch> |
| 193 | |
| 194 | After completing this it is the project maintainers job to apply your patches to |
| 195 | the master branch. |
| 196 | |
| 197 | .. _fork a repo: https://help.github.com/articles/fork-a-repo |
| 198 | .. _GitHub: https://github.com |
| 199 | .. _Connecting to GitHub with SSH: https://help.github.com/articles/connecting-to-github-with-ssh |
| 200 | .. _pull request: https://help.github.com/articles/creating-a-pull-request |
| 201 | |