| 1 | How to Submit Patches to the libseccomp-golang Project |
| 2 | =============================================================================== |
| 3 | https://github.com/seccomp/libseccomp-golang |
| 4 | |
| 5 | This document is intended to act as a guide to help you contribute to the |
| 6 | libseccomp-golang project. It is not perfect, and there will always be |
| 7 | exceptions to the rules described here, but by following the instructions below |
| 8 | you should have a much easier time getting your work merged with the upstream |
| 9 | project. |
| 10 | |
| 11 | ## Test Your Code Using Existing Tests |
| 12 | |
| 13 | A number of tests and lint related recipes are provided in the Makefile, if |
| 14 | you want to run the standard regression tests, you can execute the following: |
| 15 | |
| 16 | # make check |
| 17 | |
| 18 | In order to use it, the 'golangci-lint' tool is needed, which can be found at: |
| 19 | |
| 20 | * https://github.com/golangci/golangci-lint |
| 21 | |
| 22 | ## Add New Tests for New Functionality |
| 23 | |
| 24 | Any submissions which add functionality, or significantly change the existing |
| 25 | code, should include additional tests to verify the proper operation of the |
| 26 | proposed changes. |
| 27 | |
| 28 | ## Explain Your Work |
| 29 | |
| 30 | At the top of every patch you should include a description of the problem you |
| 31 | are trying to solve, how you solved it, and why you chose the solution you |
| 32 | implemented. If you are submitting a bug fix, it is also incredibly helpful |
| 33 | if you can describe/include a reproducer for the problem in the description as |
| 34 | well as instructions on how to test for the bug and verify that it has been |
| 35 | fixed. |
| 36 | |
| 37 | ## Sign Your Work |
| 38 | |
| 39 | The sign-off is a simple line at the end of the patch description, which |
| 40 | certifies that you wrote it or otherwise have the right to pass it on as an |
| 41 | open-source patch. The "Developer's Certificate of Origin" pledge is taken |
| 42 | from the Linux Kernel and the rules are pretty simple: |
| 43 | |
| 44 | Developer's Certificate of Origin 1.1 |
| 45 | |
| 46 | By making a contribution to this project, I certify that: |
| 47 | |
| 48 | (a) The contribution was created in whole or in part by me and I |
| 49 | have the right to submit it under the open source license |
| 50 | indicated in the file; or |
| 51 | |
| 52 | (b) The contribution is based upon previous work that, to the best |
| 53 | of my knowledge, is covered under an appropriate open source |
| 54 | license and I have the right under that license to submit that |
| 55 | work with modifications, whether created in whole or in part |
| 56 | by me, under the same open source license (unless I am |
| 57 | permitted to submit under a different license), as indicated |
| 58 | in the file; or |
| 59 | |
| 60 | (c) The contribution was provided directly to me by some other |
| 61 | person who certified (a), (b) or (c) and I have not modified |
| 62 | it. |
| 63 | |
| 64 | (d) I understand and agree that this project and the contribution |
| 65 | are public and that a record of the contribution (including all |
| 66 | personal information I submit with it, including my sign-off) is |
| 67 | maintained indefinitely and may be redistributed consistent with |
| 68 | this project or the open source license(s) involved. |
| 69 | |
| 70 | ... then you just add a line to the bottom of your patch description, with |
| 71 | your real name, saying: |
| 72 | |
| 73 | Signed-off-by: Random J Developer <[email protected]> |
| 74 | |
| 75 | You can add this to your commit description in `git` with `git commit -s` |
| 76 | |
| 77 | ## Post Your Patches Upstream |
| 78 | |
| 79 | The libseccomp project accepts both GitHub pull requests and patches sent via |
| 80 | the mailing list. GitHub pull requests are preferred. This sections below |
| 81 | explain how to contribute via either method. Please read each step and perform |
| 82 | all steps that apply to your chosen contribution method. |
| 83 | |
| 84 | ### Submitting via Email |
| 85 | |
| 86 | Depending on how you decided to work with the libseccomp code base and what |
| 87 | tools you are using there are different ways to generate your patch(es). |
| 88 | However, regardless of what tools you use, you should always generate your |
| 89 | patches using the "unified" diff/patch format and the patches should always |
| 90 | apply to the libseccomp source tree using the following command from the top |
| 91 | directory of the libseccomp sources: |
| 92 | |
| 93 | # patch -p1 < changes.patch |
| 94 | |
| 95 | If you are not using git, stacked git (stgit), or some other tool which can |
| 96 | generate patch files for you automatically, you may find the following command |
| 97 | helpful in generating patches, where "libseccomp.orig/" is the unmodified |
| 98 | source code directory and "libseccomp/" is the source code directory with your |
| 99 | changes: |
| 100 | |
| 101 | # diff -purN libseccomp.orig/ libseccomp/ |
| 102 | |
| 103 | When in doubt please generate your patch and try applying it to an unmodified |
| 104 | copy of the libseccomp sources; if it fails for you, it will fail for the rest |
| 105 | of us. |
| 106 | |
| 107 | Finally, you will need to email your patches to the mailing list so they can |
| 108 | be reviewed and potentially merged into the main libseccomp repository. When |
| 109 | sending patches to the mailing list it is important to send your email in text |
| 110 | form, no HTML mail please, and ensure that your email client does not mangle |
| 111 | your patches. It should be possible to save your raw email to disk and apply |
| 112 | it directly to the libseccomp source code; if that fails then you likely have |
| 113 | a problem with your email client. When in doubt try a test first by sending |
| 114 | yourself an email with your patch and attempting to apply the emailed patch to |
| 115 | the libseccomp repository; if it fails for you, it will fail for the rest of |
| 116 | us trying to test your patch and include it in the main libseccomp repository. |
| 117 | |
| 118 | ### Submitting via GitHub |
| 119 | |
| 120 | See [this guide](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) if you've never done this before. |