2018-06-15 17:03:38 +02:00
|
|
|
Contribution Guidelines
|
|
|
|
=======================
|
|
|
|
|
|
|
|
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
|
|
|
|
**Table of Contents**
|
|
|
|
|
|
|
|
- [Contribution Guidelines](#contribution-guidelines)
|
|
|
|
- [Before making a change](#before-making-a-change)
|
|
|
|
- [Commit messages](#commit-messages)
|
|
|
|
- [Commit content](#commit-content)
|
|
|
|
- [Code quality](#code-quality)
|
|
|
|
- [Builds & tests](#builds--tests)
|
2020-06-17 04:23:37 +02:00
|
|
|
- [Submitting changes](#submitting-changes)
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
<!-- markdown-toc end -->
|
|
|
|
|
2020-06-12 04:09:54 +02:00
|
|
|
This is a loose set of "guidelines" for contributing to the depot. Please note
|
|
|
|
that we will not accept any patches that don't follow these guidelines.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2020-06-19 07:55:28 +02:00
|
|
|
Also consider the [code of conduct](./CODE_OF_CONDUCT.md). No really,
|
2019-12-20 21:37:02 +01:00
|
|
|
you should.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
## Before making a change
|
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
Before making a change, consider your motivation for making the change.
|
|
|
|
Documentation updates, bug fixes and the like are *always* welcome.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
When adding a feature you should consider whether it is only useful for your
|
|
|
|
particular use-case or whether it is generally applicable for other users of the
|
|
|
|
project.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2022-12-25 13:05:31 +01:00
|
|
|
When in doubt - just ask! You can reach out to us via mail at
|
|
|
|
[depot@tvl.su](mailto:depot@tvl.su) or on IRC.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
## Commit messages
|
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
All commit messages should be structured like this:
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
```
|
2019-12-20 20:53:17 +01:00
|
|
|
type(scope): Subject line with at most a 68 character length
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
Body of the commit message with an empty line between subject and
|
|
|
|
body. This text should explain what the change does and why it has
|
|
|
|
been made, *especially* if it introduces a new feature.
|
|
|
|
|
|
|
|
Relevant issues should be mentioned if they exist.
|
|
|
|
```
|
|
|
|
|
|
|
|
Where `type` can be one of:
|
|
|
|
|
|
|
|
* `feat`: A new feature has been introduced
|
|
|
|
* `fix`: An issue of some kind has been fixed
|
|
|
|
* `docs`: Documentation or comments have been updated
|
|
|
|
* `style`: Formatting changes only
|
|
|
|
* `refactor`: Hopefully self-explanatory!
|
|
|
|
* `test`: Added missing tests / fixed tests
|
|
|
|
* `chore`: Maintenance work
|
2021-11-29 17:50:56 +01:00
|
|
|
* `subtree`: Operations involving `git subtree`
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
And `scope` should refer to some kind of logical grouping inside of the project.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2020-06-12 04:09:54 +02:00
|
|
|
It does not make sense to include the full path unless it aids in
|
|
|
|
disambiguating. For example, when changing the configuration of the host
|
2021-04-11 22:50:30 +02:00
|
|
|
`whitby` at `//ops/machines/whitby` it is enough to write `feat(whitby): ...`.
|
2020-06-12 04:09:54 +02:00
|
|
|
|
2018-06-15 17:03:38 +02:00
|
|
|
Please take a look at the existing commit log for examples.
|
|
|
|
|
|
|
|
## Commit content
|
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
Multiple changes should be divided into multiple git commits whenever possible.
|
|
|
|
Common sense applies.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
The fix for a single-line whitespace issue is fine to include in a different
|
|
|
|
commit. Introducing a new feature and refactoring (unrelated) code in the same
|
|
|
|
commit is not fine.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
`git commit -a` is generally **taboo**.
|
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
In my experience making "sane" commits becomes *significantly* easier as
|
|
|
|
developer tooling is improved. The interface to `git` that I recommend is
|
|
|
|
[magit][]. Even if you are not yet an Emacs user, it makes sense to install
|
|
|
|
Emacs just to be able to use magit - it is really that good.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
For staging sane chunks on the command line with only git, consider `git add
|
|
|
|
-p`.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
## Code quality
|
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
This one should go without saying - but please ensure that your code quality
|
|
|
|
does not fall below the rest of the project. This is of course very subjective,
|
|
|
|
but as an example if you place code that throws away errors into a block in
|
|
|
|
which errors are handled properly your change will be rejected.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
In my experience there is a strong correlation between the visual appearance of
|
|
|
|
a code block and its quality. This is a simple way to sanity-check your work
|
|
|
|
while squinting and keeping some distance from your screen ;-)
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
## Builds & tests
|
|
|
|
|
2020-06-12 04:09:54 +02:00
|
|
|
All projects are built using [Nix][] to avoid "build pollution" via the user's
|
2019-12-20 20:53:17 +01:00
|
|
|
environment.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
If you have Nix installed and are contributing to a project tracked in this
|
|
|
|
repository, you can usually build the project by calling `nix-build -A
|
|
|
|
path.to.project`.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2020-06-12 04:09:54 +02:00
|
|
|
For example, to build a project located at `//tools/foo` you would call
|
|
|
|
`nix-build -A tools.foo`
|
2018-06-15 17:03:38 +02:00
|
|
|
|
2019-12-20 20:53:17 +01:00
|
|
|
If the project has tests, check that they still work before submitting your
|
|
|
|
change.
|
|
|
|
|
2020-06-12 04:09:54 +02:00
|
|
|
## Submitting changes
|
|
|
|
|
2020-06-17 04:23:37 +02:00
|
|
|
The code review & change submission process is described in the [code
|
|
|
|
review][] documentation.
|
2018-06-15 17:03:38 +02:00
|
|
|
|
|
|
|
[magit]: https://magit.vc/
|
|
|
|
[Nix]: https://nixos.org/nix/
|
2020-06-17 04:23:37 +02:00
|
|
|
[code review]: ./REVIEWS.md
|