|
Packit |
ea1746 |
.. _chapter-contributing:
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
============
|
|
Packit |
ea1746 |
Contributing
|
|
Packit |
ea1746 |
============
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
We welcome contributions to Ceres, whether they are new features, bug
|
|
Packit |
ea1746 |
fixes or tests. The Ceres `mailing
|
|
Packit |
ea1746 |
<http://groups.google.com/group/ceres-solver>`_ list is the best place
|
|
Packit |
ea1746 |
for all development related discussions. Please consider joining
|
|
Packit |
ea1746 |
it. If you have ideas on how you would like to contribute to Ceres, it
|
|
Packit |
ea1746 |
is a good idea to let us know on the mailing list before you start
|
|
Packit |
ea1746 |
development. We may have suggestions that will save effort when trying
|
|
Packit |
ea1746 |
to merge your work into the main branch. If you are looking for ideas,
|
|
Packit |
ea1746 |
please let us know about your interest and skills and we will be happy
|
|
Packit |
ea1746 |
to make a suggestion or three.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
We follow Google's `C++ Style Guide
|
|
Packit |
ea1746 |
<http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml>`_ and
|
|
Packit |
ea1746 |
use `git <http://git-scm.com/>`_ for version control. We use the
|
|
Packit |
ea1746 |
`Gerrit <https://ceres-solver-review.googlesource.com/>`_ to collaborate and
|
|
Packit |
ea1746 |
review changes to Ceres. Gerrit enables pre-commit reviews so that
|
|
Packit |
ea1746 |
Ceres can maintain a linear history with clean, reviewed commits, and
|
|
Packit |
ea1746 |
no merges.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
We now describe how to set up your development environment and submit
|
|
Packit |
ea1746 |
a change list for review via Gerrit.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
Setting up your Environment
|
|
Packit |
ea1746 |
===========================
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
1. Download and configure ``git``.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
* Mac ``brew install git``.
|
|
Packit |
ea1746 |
* Linux ``sudo apt-get install git``.
|
|
Packit |
ea1746 |
* Windows. Download `msysgit
|
|
Packit |
ea1746 |
<https://code.google.com/p/msysgit/>`_, which includes a minimal
|
|
Packit |
ea1746 |
`Cygwin <http://www.cygwin.com/>`_ install.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
2. Sign up for `Gerrit
|
|
Packit |
ea1746 |
<https://ceres-solver-review.googlesource.com/>`_. You will also
|
|
Packit |
ea1746 |
need to sign the Contributor License Agreement (CLA) with Google,
|
|
Packit |
ea1746 |
which gives Google a royalty-free unlimited license to use your
|
|
Packit |
ea1746 |
contributions. You retain copyright.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
3. Clone the Ceres Solver ``git`` repository from Gerrit.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
.. code-block:: bash
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
git clone https://ceres-solver.googlesource.com/ceres-solver
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
4. Build Ceres, following the instructions in
|
|
Packit |
ea1746 |
:ref:`chapter-installation`.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
On Mac and Linux, the ``CMake`` build will download and enable
|
|
Packit |
ea1746 |
the Gerrit pre-commit hook automatically. This pre-submit hook
|
|
Packit |
ea1746 |
creates `Change-Id: ...` lines in your commits.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
If this does not work OR you are on Windows, execute the
|
|
Packit |
ea1746 |
following in the root directory of the local ``git`` repository:
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
.. code-block:: bash
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
curl -o .git/hooks/commit-msg https://ceres-solver-review.googlesource.com/tools/hooks/commit-msg
|
|
Packit |
ea1746 |
chmod +x .git/hooks/commit-msg
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
5. Configure your Gerrit password with a ``.gitcookies`` which allows pushing
|
|
Packit |
ea1746 |
to Gerrit without having to enter a very long random password every time:
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
* Sign into `http://ceres-solver-review.googlesource.com
|
|
Packit |
ea1746 |
<http://ceres-solver-review.googlesource.com>`_.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
* Click ``Settings -> HTTP Password -> Obtain Password``.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
* (maybe) Select an account for multi-login. This should be the
|
|
Packit |
ea1746 |
same as your Gerrit login.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
* Click ``Allow access`` when the page requests access to your
|
|
Packit |
ea1746 |
``git`` repositories.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
* Follow the instructions from Gerrit to create a ``.gitcookies`` file on
|
|
Packit |
ea1746 |
your system, either in ``$HOME/.gitcookies`` (Mac and Linux) or
|
|
Packit |
ea1746 |
``%USERPROFILE%\.gitcookies`` (Windows). Note that for Windows, please get
|
|
Packit |
ea1746 |
a recent `Git for Windows <https://git-scm.com/download/win>`_ install to
|
|
Packit |
ea1746 |
enable automatic lookup in the ``%USERPROFILE%\.gitcookies``.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
Submitting a change
|
|
Packit |
ea1746 |
===================
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
1. Make your changes against master or whatever branch you
|
|
Packit |
ea1746 |
like. Commit your changes as one patch. When you commit, the Gerrit
|
|
Packit |
ea1746 |
hook will add a `Change-Id:` line as the last line of the commit.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
Make sure that your commit message is formatted in the `50/72 style
|
|
Packit |
ea1746 |
<http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
2. Push your changes to the Ceres Gerrit instance:
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
.. code-block:: bash
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
git push origin HEAD:refs/for/master
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
When the push succeeds, the console will display a URL showing the
|
|
Packit |
ea1746 |
address of the review. Go to the URL and add at least one of the
|
|
Packit |
ea1746 |
maintainers (Sameer Agarwal, Keir Mierle, Alex Stewart or William
|
|
Packit |
ea1746 |
Rucklidge) as reviewers.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
3. Wait for a review.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
4. Once review comments come in, address them. Please reply to each
|
|
Packit |
ea1746 |
comment in Gerrit, which makes the re-review process easier. After
|
|
Packit |
ea1746 |
modifying the code in your ``git`` instance, *don't make a new
|
|
Packit |
ea1746 |
commit*. Instead, update the last commit using a command like the
|
|
Packit |
ea1746 |
following:
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
.. code-block:: bash
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
git commit --amend -a
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
This will update the last commit, so that it has both the original
|
|
Packit |
ea1746 |
patch and your updates as a single commit. You will have a chance
|
|
Packit |
ea1746 |
to edit the commit message as well. Push the new commit to Gerrit
|
|
Packit |
ea1746 |
as before.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
Gerrit will use the ``Change-Id:`` to match the previous commit
|
|
Packit |
ea1746 |
with the new one. The review interface retains your original patch,
|
|
Packit |
ea1746 |
but also shows the new patch.
|
|
Packit |
ea1746 |
|
|
Packit |
ea1746 |
Publish your responses to the comments, and wait for a new round
|
|
Packit |
ea1746 |
of reviews.
|