xref: /freebsd/CONTRIBUTING.md (revision 9f0f30bc1f5f08d25243952bad3fdc6e13a75c2a)
1# Contribution Guidelines for GitHub
2
3## General Contributions to FreeBSD
4
5Please read the guidelines in [Contributing to FreeBSD](https://docs.freebsd.org/en/articles/contributing/)
6for all the ways you can contribute to the project, how the project is organized,
7how to build different parts of the project, etc. The
8[developer's handbook](https://docs.freebsd.org/en/books/developers-handbook/)
9is another useful resource.
10
11FreeBSD accepts source code contributions using one of several methods:
12- A GitHub [pull request](https://github.com/freebsd/freebsd-src/pulls)
13- A code review in [Phabricator](https://reviews.freebsd.org/differential)
14- An attachment on a [Bugzilla ticket](https://bugs.freebsd.org)
15- Direct access to the [Git repository](https://cgit.freebsd.org/src/)
16
17The preferred method depends on a few factors including the size or scope of
18the change.  GitHub pull requests are preferred for relatively straightforward
19changes where the contributor already has a GitHub account.
20
21A change should be submitted by only one method.  For example, please do not
22open a GitHub pull request and create a Phabricator review for the same change
23(unless explicitly requested to do so by a FreeBSD committer).
24
25## GitHub Pull Requests
26
27Presently, GitHub 'freebsd-src' repository is one of the publish-only services
28for the FreeBSD 'src' repository the project uses to promote collaboration and
29contribution.  Pull requests that need little developer time, are generally
30small, and have limited scope should be submitted. Do not submit pull requests
31that are security-related, problem reports, works in progress, changes that are controversial
32and need discussion, or changes that require specialized review.
33
34A pull request will be considered if:
35
36* The request is substantive in nature. We generally don't accept minor or cosmetic changes unless they are part of larger work in that area. Pull requests should solve a real, actual problem.
37* 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.
38* It passes all the GitHub CI jobs.
39* You can respond to feedback quickly. If feedback is requested and one month passes without a response we may close the pull request.
40* 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.
41* 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).
42* 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.
43* 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.
44* Fixup commits should be squashed with the commit they are fixing. Each commit in your branch should be suitable for FreeBSD's repository.
45* Commits should include one or more `Signed-off-by:` lines with full name and email address certifying [Developer Certificate of Origin](https://developercertificate.org/).
46* The commits follow FreeBSD's style guide. See [Style](#Style).
47* Run tools/build/checkstyle9.pl on your Git branch and eliminate all errors, or provide an explanation for exceptions.
48* The commits do not introduce trailing white space.
49* If the commit fixes a bug, please add 'PR: \<bugnumber\>' to the commit message to document the Bugzilla Problem Report number.
50* If there's a code review related to this change, please include its URL in the commit message. However, where possible, please do not open both a differential review and a GitHub pull request.
51* If you have run FreeBSD's sources through a static analysis tool, please don't submit the raw results. Please also see the chunking up guidelines. Also, please make sure that kyua tests are the same before / after your change. Ideally, you'd also create a test case that shows an actual bug that's being fixed by these changes.
52* FreeBSD committers submitting pull requests are responsible for pushing them into the tree (possibly with approval if cross-repo commit bit policy needs it). Pull requests by FreeBSD committers will be closed after a month unless there's a very good reason not to.
53* Submissions using generative AI will be rejected.
54* Submissions from AI chatbots will result in the account being banned.
55
56When updating your pull request, please rebase with a forced push rather than a
57merge commit.
58
59More complex changes may be submitted as pull requests, but they may be closed
60if they are too large, too unwieldy, become inactive, need further discussion in
61the community, or need extensive revision.  Please avoid creating large,
62wide-ranging cleanup patches: they are too large and lack the focus needed for a
63good review.  Misdirected patches may be redirected to a more appropriate forum
64for the patch to be resolved.
65
66Please make sure that your submissions compile and work before submitting. If
67you need feedback, a pull request might not be the right place (it may just be
68summarily closed if there are too many obvious mistakes).
69
70If you want to cleanup style or older coding conventions in preparation for some
71other commit, please go ahead and prepare those patches. However, please avoid just
72cleaning up to make it cleaner, unless there's a clear advantage to doing
73so. While the project strives to have a uniform coding style, our style offers a
74range of choices making some 'cleanups' ambiguous at best. Also, some files have
75their own consistent style that deviates from style(9). Style changes take
76volunteer time to process, but that time can be quite limited, so please be
77respectful. Trivial spelling changes should generally not be made in isolation
78as they usually add little value, but do take up valuable volunteer time.
79
80The current theory for pull requests on GitHub is to facilitate inclusion in the
81project. The guidelines are streamlined for quick decisions about each pull
82request. Unless explicitly stated, rejection here as "not ready" or "too large"
83does not mean the project is uninterested in the work, it just means the
84submission does not meet the limited scope for pull requests accepted
85here. Sometimes it is easier to review a GitHub pull request than to do the
86review in Phabricator, so that's also allowed.
87
88Finally, if we close a pull request because it's not ready yet, or stalled out,
89please don't give up. You can resubmit them later once you have time to finish
90the work, or to have them reconsidered if you think we've made an error in
91closing it.
92
93### Author Name and Email
94
95We require that contributions are associated with a unique identity.
96The author email address should not be `<something>@users.noreply.github.com`.
97Do note that your name and email address will become a permanent and immutable
98part of the public Git history of the FreeBSD source tree. Authors that use
99pseudonyms will be considered on a case by case basis.
100
101## Style
102
103Avoid adding trailing newlines and whitespace. These slow down the integration
104process and are a distraction. `git diff` will highlight them in red, as will
105the Files Changed tab in the pull request.
106
107For C programs, see [style(9)](https://man.freebsd.org/cgi/man.cgi?query=style&sektion=9)
108for details. You can use [Clang format](https://clang.llvm.org/docs/ClangFormat.html)
109with the top level .clang-format file if you are unsure. The
110[git clang-format](https://github.com/llvm-mirror/clang/blob/master/tools/clang-format/git-clang-format)
111command can help minimize churn by only formatting the areas nearby the changes. While
112not perfect, using these tools will maximize your chances of not having style
113comments on your pull requests.
114
115For [Lua](https://www.lua.org), see
116[style.lua(9)](https://man.freebsd.org/cgi/man.cgi?query=style.lua&sektion=9)
117for details. Lua is used for the boot loader and a few scripts in the base system.
118
119For Makefiles changes, see
120[style.Makefile(5)](https://man.freebsd.org/cgi/man.cgi?query=style.Makefile&sektion=5)
121for details. FreeBSD's base system uses the in-tree make, not GNU Make, so
122[make(1)](https://man.freebsd.org/cgi/man.cgi?query=make&sektion=1) is another useful
123resource.
124
125For manual page changes, see
126[style.mdoc(5)](https://man.freebsd.org/cgi/man.cgi?query=style.mdoc&sektion=5)
127for details. Changes should pass `mandoc -Tlint` and igor (install the latter with `pkg install igor`).
128Please be sure to observe the one-sentence-per-line rule so manual pages properly render.
129Proposed changes to manual pages should not bump the document date until merged.
130
131For shell scripts, avoid using bash. The system shell (/bin/sh) is preferred.
132Shell scripts in the base system cannot use bash or bash extensions
133not present in FreeBSD's [shell](https://man.freebsd.org/cgi/man.cgi?query=sh&sektion=1).
134
135## Signed-off-by
136
137Other projects mandate Signed-off-by to create a paper trail for contributions they
138receive. The Developer Certificate of Origin is an attestation that the person
139making the contribution can do it under the current license of the file. Other
140projects that have 'delegated' hierarchies also use it when maintainers
141integrate these patches and submit them upstream.
142
143Right now, pull requests on GitHub are an experimental feature. We strongly
144suggest that people add this line. It creates a paper trail for infrequent
145contributors. Also, developers that are landing a pull request will use a
146Signed-off-by line to set the author for the commit.
147
148These lines are easy to add with `git commit -s`.
149
150## Submitting as part of class work
151
152If you are a professor or teacher that wishes to have your students submit fixes
153as part of their class work, please contact imp@FreeBSD.org before the semester
154to ensure we allocate the proper resources to process them quickly. We'll give
155you more details when you contact us and thanks for including FreeBSD in your
156class work. It also helps us keep track.
157
158## FreeBSD's Upstreams
159
160Anything that's in the directory `contrib`, `crypto`, `sys/contrib`,
161`sys/crypto/` or `sys/cddl` likely has an upstream we pull from. Please do a
162`git log --merges` in any subdirectory of these you are submitting patches for
163to find out the last time we merged from upstream. If it is in the last 5 years,
164upstream is "active" and you should submit your patches there and let the last
165few people to commit to this file (especially merge commits) know. If it's been
166more than 5 years, upstream is likely inactive so please submit the patch. We
167can sort out if it should go into FreeBSD or upstream.
168