2019-06-12 21:42:43 +00:00
|
|
|
[TOC]
|
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
# Short Version
|
2009-07-02 20:18:42 +00:00
|
|
|
|
|
|
|
- Make small logical changes.
|
2021-11-14 05:12:00 +00:00
|
|
|
- [Provide a meaningful commit message][commit-message-style].
|
2009-07-02 20:18:42 +00:00
|
|
|
- Make sure all code is under the Apache License, 2.0.
|
2016-02-17 01:30:44 +00:00
|
|
|
- Publish your changes for review.
|
|
|
|
- Make corrections if requested.
|
|
|
|
- Verify your changes on gerrit so they can be submitted.
|
2009-07-02 20:18:42 +00:00
|
|
|
|
2020-11-15 23:42:26 +00:00
|
|
|
`git push https://gerrit-review.googlesource.com/git-repo HEAD:refs/for/main`
|
2009-07-02 20:18:42 +00:00
|
|
|
|
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
# Long Version
|
2009-07-02 20:18:42 +00:00
|
|
|
|
|
|
|
I wanted a file describing how to submit patches for repo,
|
|
|
|
so I started with the one found in the core Git distribution
|
|
|
|
(Documentation/SubmittingPatches), which itself was based on the
|
|
|
|
patch submission guidelines for the Linux kernel.
|
|
|
|
|
|
|
|
However there are some differences, so please review and familiarize
|
2016-08-16 04:08:37 +00:00
|
|
|
yourself with the following relevant bits.
|
2009-07-02 20:18:42 +00:00
|
|
|
|
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
## Make separate commits for logically separate changes.
|
2009-07-02 20:18:42 +00:00
|
|
|
|
2021-11-14 05:12:00 +00:00
|
|
|
Unless your patch is really trivial, you should not be sending out a patch that
|
|
|
|
was generated between your working tree and your commit head.
|
|
|
|
Instead, always make a commit with a complete
|
|
|
|
[commit message][commit-message-style] and generate a series of patches from
|
|
|
|
your repository.
|
2009-07-02 20:18:42 +00:00
|
|
|
It is a good discipline.
|
|
|
|
|
|
|
|
Describe the technical detail of the change(s).
|
|
|
|
|
|
|
|
If your description starts to get too long, that's a sign that you
|
|
|
|
probably need to split up your commit to finer grained pieces.
|
|
|
|
|
|
|
|
|
2023-03-11 04:35:22 +00:00
|
|
|
## Linting and formatting code
|
2012-10-22 03:50:15 +00:00
|
|
|
|
2023-03-11 04:35:22 +00:00
|
|
|
Lint any changes by running:
|
|
|
|
```sh
|
|
|
|
$ tox -e lint -- file.py
|
|
|
|
```
|
2016-09-02 05:20:38 +00:00
|
|
|
|
2023-03-11 04:35:22 +00:00
|
|
|
And format with:
|
|
|
|
```sh
|
|
|
|
$ tox -e format -- file.py
|
|
|
|
```
|
2016-09-02 05:20:38 +00:00
|
|
|
|
2023-03-11 04:35:22 +00:00
|
|
|
Or format everything:
|
|
|
|
```sh
|
|
|
|
$ tox -e format
|
|
|
|
```
|
2020-02-13 01:34:05 +00:00
|
|
|
|
2023-03-11 04:35:22 +00:00
|
|
|
Repo uses [black](https://black.readthedocs.io/) with line length of 80 as its
|
|
|
|
formatter and flake8 as its linter. Repo also follows
|
|
|
|
[Google's Python Style Guide].
|
2020-02-13 01:34:05 +00:00
|
|
|
|
2020-02-15 04:51:17 +00:00
|
|
|
There should be no new errors or warnings introduced.
|
2016-09-02 05:20:38 +00:00
|
|
|
|
2020-02-15 04:51:17 +00:00
|
|
|
Warnings that cannot be avoided without going against the Google Style Guide
|
|
|
|
may be suppressed inline individally using a `# noqa` comment as described
|
|
|
|
in the [flake8 documentation].
|
2012-10-22 03:50:15 +00:00
|
|
|
|
2020-02-15 04:51:17 +00:00
|
|
|
If there are many occurrences of the same warning, these may be suppressed for
|
|
|
|
the entire project in the included `.flake8` file.
|
2019-06-12 21:42:43 +00:00
|
|
|
|
2020-02-15 04:51:17 +00:00
|
|
|
[Google's Python Style Guide]: https://google.github.io/styleguide/pyguide.html
|
|
|
|
[PEP 8]: https://www.python.org/dev/peps/pep-0008/
|
|
|
|
[flake8 documentation]: https://flake8.pycqa.org/en/3.1.1/user/ignoring-errors.html#in-line-ignoring-errors
|
2019-06-12 21:42:43 +00:00
|
|
|
|
|
|
|
## Running tests
|
|
|
|
|
2019-12-02 03:47:21 +00:00
|
|
|
We use [pytest](https://pytest.org/) and [tox](https://tox.readthedocs.io/) for
|
|
|
|
running tests. You should make sure to install those first.
|
2019-06-12 21:42:43 +00:00
|
|
|
|
2019-12-02 03:47:21 +00:00
|
|
|
To run the full suite against all supported Python versions, simply execute:
|
|
|
|
```sh
|
|
|
|
$ tox -p auto
|
|
|
|
```
|
|
|
|
|
|
|
|
We have [`./run_tests`](./run_tests) which is a simple wrapper around `pytest`:
|
|
|
|
```sh
|
|
|
|
# Run the full suite against the default Python version.
|
|
|
|
$ ./run_tests
|
|
|
|
# List each test as it runs.
|
|
|
|
$ ./run_tests -v
|
|
|
|
|
|
|
|
# Run a specific unittest module (and all tests in it).
|
|
|
|
$ ./run_tests tests/test_git_command.py
|
|
|
|
|
|
|
|
# Run a specific testsuite in a specific unittest module.
|
|
|
|
$ ./run_tests tests/test_editor.py::EditString
|
|
|
|
|
|
|
|
# Run a single test.
|
|
|
|
$ ./run_tests tests/test_editor.py::EditString::test_cat_editor
|
|
|
|
|
|
|
|
# List all available tests.
|
|
|
|
$ ./run_tests --collect-only
|
|
|
|
|
|
|
|
# Run a single test using substring match.
|
|
|
|
$ ./run_tests -k test_cat_editor
|
|
|
|
```
|
|
|
|
|
|
|
|
The coverage isn't great currently, but it should still be run for all commits.
|
2019-06-12 21:42:43 +00:00
|
|
|
Adding more unittests for changes you make would be greatly appreciated :).
|
|
|
|
Check out the [tests/](./tests/) subdirectory for more details.
|
|
|
|
|
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
## Check the license
|
2009-07-02 20:18:42 +00:00
|
|
|
|
|
|
|
repo is licensed under the Apache License, 2.0.
|
|
|
|
|
|
|
|
Because of this licensing model *every* file within the project
|
|
|
|
*must* list the license that covers it in the header of the file.
|
|
|
|
Any new contributions to an existing file *must* be submitted under
|
|
|
|
the current license of that file. Any new files *must* clearly
|
|
|
|
indicate which license they are provided under in the file header.
|
|
|
|
|
|
|
|
Please verify that you are legally allowed and willing to submit your
|
|
|
|
changes under the license covering each file *prior* to submitting
|
|
|
|
your patch. It is virtually impossible to remove a patch once it
|
|
|
|
has been applied and pushed out.
|
|
|
|
|
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
## Sending your patches.
|
2009-07-02 20:18:42 +00:00
|
|
|
|
|
|
|
Do not email your patches to anyone.
|
|
|
|
|
|
|
|
Instead, login to the Gerrit Code Review tool at:
|
|
|
|
|
2012-02-29 02:53:12 +00:00
|
|
|
https://gerrit-review.googlesource.com/
|
2009-07-02 20:18:42 +00:00
|
|
|
|
|
|
|
Ensure you have completed one of the necessary contributor
|
|
|
|
agreements, providing documentation to the project maintainers that
|
|
|
|
they have right to redistribute your work under the Apache License:
|
|
|
|
|
2012-02-29 02:53:12 +00:00
|
|
|
https://gerrit-review.googlesource.com/#/settings/agreements
|
2009-07-02 20:18:42 +00:00
|
|
|
|
2012-02-29 02:53:12 +00:00
|
|
|
Ensure you have obtained an HTTP password to authenticate:
|
2009-07-02 20:18:42 +00:00
|
|
|
|
2012-02-29 02:53:12 +00:00
|
|
|
https://gerrit-review.googlesource.com/new-password
|
2009-07-02 20:18:42 +00:00
|
|
|
|
2016-02-17 01:30:44 +00:00
|
|
|
Ensure that you have the local commit hook installed to automatically
|
|
|
|
add a ChangeId to your commits:
|
|
|
|
|
|
|
|
curl -Lo `git rev-parse --git-dir`/hooks/commit-msg https://gerrit-review.googlesource.com/tools/hooks/commit-msg
|
|
|
|
chmod +x `git rev-parse --git-dir`/hooks/commit-msg
|
|
|
|
|
|
|
|
If you have already committed your changes you will need to amend the commit
|
|
|
|
to get the ChangeId added.
|
|
|
|
|
|
|
|
git commit --amend
|
|
|
|
|
2012-02-29 02:53:12 +00:00
|
|
|
Push your patches over HTTPS to the review server, possibly through
|
2009-07-02 20:18:42 +00:00
|
|
|
a remembered remote to make this easier in the future:
|
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
git config remote.review.url https://gerrit-review.googlesource.com/git-repo
|
2020-11-15 23:42:26 +00:00
|
|
|
git config remote.review.push HEAD:refs/for/main
|
2009-07-02 20:18:42 +00:00
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
git push review
|
2009-07-02 20:18:42 +00:00
|
|
|
|
|
|
|
You will be automatically emailed a copy of your commits, and any
|
|
|
|
comments made by the project maintainers.
|
2016-02-17 01:30:44 +00:00
|
|
|
|
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
## Make changes if requested
|
2016-02-17 01:30:44 +00:00
|
|
|
|
|
|
|
The project maintainer who reviews your changes might request changes to your
|
|
|
|
commit. If you make the requested changes you will need to amend your commit
|
|
|
|
and push it to the review server again.
|
|
|
|
|
|
|
|
|
2016-08-16 04:08:37 +00:00
|
|
|
## Verify your changes on gerrit
|
2016-02-17 01:30:44 +00:00
|
|
|
|
|
|
|
After you receive a Code-Review+2 from the maintainer, select the Verified
|
|
|
|
button on the gerrit page for the change. This verifies that you have tested
|
|
|
|
your changes and notifies the maintainer that they are ready to be submitted.
|
|
|
|
The maintainer will then submit your changes to the repository.
|
2021-11-14 05:12:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
[commit-message-style]: https://chris.beams.io/posts/git-commit/
|