xref: /freebsd-14.2/CONTRIBUTING.md (revision 0416bffd)
181ef45edSWarner Losh# Contribution Guidelines for GitHub
281ef45edSWarner Losh
381ef45edSWarner Losh## General Contributions to FreeBSD
481ef45edSWarner Losh
581ef45edSWarner LoshPlease read the guidelines in [Contributing to FreeBSD](https://docs.freebsd.org/en/articles/contributing/)
681ef45edSWarner Loshfor all the ways you can contribute to the project, how the project is organized,
781ef45edSWarner Loshhow to build different parts of the project, etc. The
881ef45edSWarner Losh[developer's handbook](https://docs.freebsd.org/en/books/developers-handbook/)
981ef45edSWarner Loshis another useful resource.
1081ef45edSWarner Losh
117f6a000fSEd MasteFreeBSD accepts source code contributions using one of several methods:
127f6a000fSEd Maste- A GitHub [pull request](https://github.com/freebsd/freebsd-src/pulls)
137f6a000fSEd Maste- A code review in [Phabricator](https://reviews.freebsd.org/differential)
147f6a000fSEd Maste- An attachment on a [Bugzilla ticket](https://bugs.freebsd.org)
157f6a000fSEd Maste- Direct access to the [Git repository](https://cgit.freebsd.org/src/)
167f6a000fSEd Maste
177f6a000fSEd MasteThe preferred method depends on a few factors including the size or scope of
187f6a000fSEd Mastethe change.  GitHub pull requests are preferred for relatively straightforward
197f6a000fSEd Mastechanges where the contributor already has a GitHub account.
207f6a000fSEd Maste
2181ef45edSWarner Losh## GitHub Pull Requests
2281ef45edSWarner Losh
2381ef45edSWarner LoshPresently, GitHub 'freebsd-src' repository is one of the publish-only services
2481ef45edSWarner Loshfor the FreeBSD 'src' repository the project uses to promote collaboration and
2581ef45edSWarner Loshcontribution.  Pull requests that need little developer time, are generally
263aa0cc47SGraham Perrinsmall, and have limited scope should be submitted. Do not submit pull requests
273aa0cc47SGraham Perrinthat are security-related, problem reports, works in progress, changes that are controversial
283aa0cc47SGraham Perrinand need discussion, or changes that require specialized review.
2981ef45edSWarner Losh
3081ef45edSWarner LoshA pull request will be considered if:
3181ef45edSWarner Losh
3281ef45edSWarner Losh* It is ready or nearly ready to be committed. A committer should be able to land the pull request with less than 10 minutes of additional work.
3381ef45edSWarner Losh* It passes all the GitHub CI jobs.
3481ef45edSWarner Losh* You can respond to feedback quickly.
3581ef45edSWarner Losh* It touches fewer than about 10 files and the changes are less than about 200 lines. Changes larger than this may be OK, or you may be asked to submit multiple pull requests of a more manageable size.
3681ef45edSWarner Losh* Each logical change is a separate commit within the pull request. Commit messages for each change should follow the [commit log message guide](https://docs.freebsd.org/en/articles/committers-guide/#commit-log-message).
373aa0cc47SGraham Perrin* All commits have, as the author, your name and valid email address as you would like to see them in the FreeBSD repository. Fake github.com addresses cannot be used.
3881ef45edSWarner Losh* The scope of the pull request should not change during review. If the review suggests changes that expand the scope, please create an independent pull request.
3981ef45edSWarner Losh* Fixup commits should be squashed with the commit they are fixing. Each commit in your branch should be suitable for FreeBSD's repository.
4005e2e803SEd Maste* Commits should include one or more `Signed-off-by:` lines with full name and email address certifying [Developer Certificate of Origin](https://developercertificate.org/).
4181ef45edSWarner Losh* The commits follow FreeBSD's style guide. See [Style](#Style).
423aa0cc47SGraham Perrin* Run tools/build/checkstyle9.pl on your Git branch and eliminate all errors
433aa0cc47SGraham Perrin* The commits do not introduce trailing white space.
44*0416bffdSrilysh* If the commit fixes a bug, please add 'PR: \<bugnumber\>' to the commit message.
453aa0cc47SGraham Perrin* If there's a code review in Phabricator, please include a link as a 'Differential Revision: ' line.
4681ef45edSWarner Losh
4781ef45edSWarner LoshWhen updating your pull request, please rebase with a forced push rather than a
4881ef45edSWarner Loshmerge commit.
4981ef45edSWarner Losh
5081ef45edSWarner LoshMore complex changes may be submitted as pull requests, but they may be closed
5181ef45edSWarner Loshif they are too large, too unwieldy, become inactive, need further discussion in
5281ef45edSWarner Loshthe community, or need extensive revision.  Please avoid creating large,
5381ef45edSWarner Loshwide-ranging cleanup patches: they are too large and lack the focus needed for a
5481ef45edSWarner Loshgood review.  Misdirected patches may be redirected to a more appropriate forum
5581ef45edSWarner Loshfor the patch to be resolved.
5681ef45edSWarner Losh
5781ef45edSWarner LoshPlease make sure that your submissions compile and work before submitting. If
5881ef45edSWarner Loshyou need feedback, a pull request might not be the right place (it may just be
5981ef45edSWarner Loshsummarily closed if there are too many obvious mistakes).
6081ef45edSWarner Losh
6181ef45edSWarner LoshIf you want to cleanup style or older coding conventions in preparation for some
6281ef45edSWarner Loshother commit, please go ahead and prepare those patches. However, please avoid just
6381ef45edSWarner Loshcleaning up to make it cleaner, unless there's a clear advantage to doing
6481ef45edSWarner Loshso. While the project strives to have a uniform coding style, our style offers a
6581ef45edSWarner Loshrange of choices making some 'cleanups' ambiguous at best. Also, some files have
6681ef45edSWarner Loshtheir own consistent style that deviates from style(9). Style changes take
6781ef45edSWarner Loshvolunteer time to process, but that time can be quite limited, so please be
6881ef45edSWarner Loshrespectful.
6981ef45edSWarner Losh
7081ef45edSWarner LoshThe current theory for pull requests on GitHub is to facilitate inclusion in the
7181ef45edSWarner Loshproject. The guidelines are streamlined for quick decisions about each pull
7281ef45edSWarner Loshrequest. Unless explicitly stated, rejection here as "not ready" or "too large"
7381ef45edSWarner Loshdoes not mean the project is uninterested in the work, it just means the
7481ef45edSWarner Loshsubmission does not meet the limited scope for pull requests accepted
7529cbe944SWuerfelDevhere. Sometimes it is easier to review a GitHub pull request than to do the
7681ef45edSWarner Loshreview in Phabricator, so that's also allowed.
7781ef45edSWarner Losh
7867e6b835SEd Maste### Author Name and Email
7967e6b835SEd Maste
8067e6b835SEd MasteWe require that contributions are associated with a unique identity.
8167e6b835SEd MasteThe author email address should not be `<something>@users.noreply.github.com`.
8267e6b835SEd MasteDo note that your name and email address will become a permanent and immutable
8367e6b835SEd Mastepart of the public Git history of the FreeBSD source tree.
8467e6b835SEd Maste
8581ef45edSWarner Losh## Style
8681ef45edSWarner Losh
8781ef45edSWarner LoshAvoid adding trailing newlines and whitespace. These slow down the integration
8881ef45edSWarner Loshprocess and are a distraction. `git diff` will highlight them in red, as will
8981ef45edSWarner Loshthe Files Changed tab in the pull request.
9081ef45edSWarner Losh
9181ef45edSWarner LoshFor C programs, see [style(9)](https://man.freebsd.org/cgi/man.cgi?query=style&sektion=9)
9281ef45edSWarner Loshfor details. You can use [Clang format](https://clang.llvm.org/docs/ClangFormat.html)
9381ef45edSWarner Loshwith the top level .clang-format file if you are unsure. The
9481ef45edSWarner Losh[git clang-format](https://github.com/llvm-mirror/clang/blob/master/tools/clang-format/git-clang-format)
9581ef45edSWarner Loshcommand can help minimize churn by only formatting the areas nearby the changes. While
9681ef45edSWarner Loshnot perfect, using these tools will maximize your chances of not having style
9781ef45edSWarner Loshcomments on your pull requests.
9881ef45edSWarner Losh
9981ef45edSWarner LoshFor Makefiles changes, see
10081ef45edSWarner Losh[style.Makefile(5)](https://man.freebsd.org/cgi/man.cgi?query=style.Makefile&sektion=5)
10181ef45edSWarner Loshfor details. FreeBSD's base system uses the in-tree make, not GNU Make, so
10281ef45edSWarner Losh[make(1)](https://man.freebsd.org/cgi/man.cgi?query=make&sektion=1) is another useful
10381ef45edSWarner Loshresource.
10481ef45edSWarner Losh
10581ef45edSWarner LoshThe project uses mdoc for all its man pages. Changes should pass `mandoc -Tlint` and igor (install the latter with `pkg install igor`).
10681ef45edSWarner LoshPlease be sure to observe the one-sentence-per-line rule so manual pages properly render. Any semantic changes to the manual pages should bump the date.
10781ef45edSWarner Losh[style.mdoc(5)](https://man.freebsd.org/cgi/man.cgi?query=style.mdoc&sektion=5) has the all details.
10881ef45edSWarner Losh
10981ef45edSWarner LoshFor [Lua](https://www.lua.org), please see
11081ef45edSWarner Losh[style.lua(9)](https://man.freebsd.org/cgi/man.cgi?query=style.lua&sektion=9)
11181ef45edSWarner Loshfor details. Lua is used for the boot loader and a few scripts in the base system.
11281ef45edSWarner Losh
11381ef45edSWarner LoshFor shell scripts, avoid using bash. The system shell (/bin/sh) is preferred.
11481ef45edSWarner LoshShell scripts in the base system cannot use bash or bash extensions
11581ef45edSWarner Loshnot present in FreeBSD's [shell](https://man.freebsd.org/cgi/man.cgi?query=sh&sektion=1).
11681ef45edSWarner Losh
11781ef45edSWarner Losh## Signed-off-by
11881ef45edSWarner Losh
11981ef45edSWarner LoshOther projects use Signed-off-by to create a paper trail for contributions they
12081ef45edSWarner Loshreceive. The Developer Certificate of Origin is an attestation that the person
12181ef45edSWarner Loshmaking the contribution can do it under the current license of the file. Other
12281ef45edSWarner Loshprojects that have 'delegated' hierarchies also use it when maintainers
12381ef45edSWarner Loshintegrate these patches and submit them upstream.
12481ef45edSWarner Losh
12581ef45edSWarner LoshRight now, pull requests on GitHub are an experimental feature. We strongly
12681ef45edSWarner Loshsuggest that people add this line. It creates a paper trail for infrequent
12781ef45edSWarner Loshcontributors. Also, developers that are landing a pull request will use a
12881ef45edSWarner LoshSigned-off-by line to set the author for the commit.
12981ef45edSWarner Losh
13081ef45edSWarner LoshThese lines are easy to add with `git commit -s`.
131