Sameer Agarwal | 3d87b72 | 2013-02-02 00:49:31 -0800 | [diff] [blame] | 1 | .. _chapter-contributing: |
| 2 | |
| 3 | ============= |
| 4 | Contributions |
| 5 | ============= |
| 6 | |
| 7 | |
| 8 | We welcome contributions to Ceres, whether they are new features, bug |
Sameer Agarwal | 480f9b8 | 2013-03-03 20:15:22 -0800 | [diff] [blame] | 9 | fixes or tests. The Ceres `mailing |
| 10 | <http://groups.google.com/group/ceres-solver>`_ list is the best place |
| 11 | for all development related discussions. Please consider joining |
| 12 | it. If you have ideas on how you would like to contribute to Ceres, it |
| 13 | is a good idea to let us know on the mailing list before you start |
Sameer Agarwal | 3d87b72 | 2013-02-02 00:49:31 -0800 | [diff] [blame] | 14 | development. We may have suggestions that will save effort when trying |
| 15 | to merge your work into the main branch. If you are looking for ideas, |
| 16 | please let us know about your interest and skills and we will be happy |
| 17 | to make a suggestion or three. |
| 18 | |
Sameer Agarwal | 480f9b8 | 2013-03-03 20:15:22 -0800 | [diff] [blame] | 19 | We follow Google's `C++ Style Guide |
| 20 | <http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml>`_ and |
Sameer Agarwal | 5d7c195 | 2013-05-07 12:47:51 -0700 | [diff] [blame] | 21 | use `git <http://git-scm.com/>`_ for version control. We use the |
Sameer Agarwal | a6b76c7 | 2013-05-09 14:58:49 -0700 | [diff] [blame] | 22 | `Gerrit <https://ceres-solver-review.googlesource.com/>`_ to collaborate and |
Sameer Agarwal | 5d7c195 | 2013-05-07 12:47:51 -0700 | [diff] [blame] | 23 | review changes to Ceres. Gerrit enables pre-commit reviews so that |
Sameer Agarwal | 480f9b8 | 2013-03-03 20:15:22 -0800 | [diff] [blame] | 24 | Ceres can maintain a linear history with clean, reviewed commits, and |
| 25 | no merges. |
| 26 | |
| 27 | We now describe how to set up your development environment and submit |
| 28 | a change list for review via Gerrit. |
| 29 | |
| 30 | Setting up your Development Environment |
| 31 | ======================================= |
| 32 | |
| 33 | 1. Download and configure ``git``. |
| 34 | |
| 35 | * Mac ``brew install git``. |
| 36 | * Linux ``sudo apt-get install git``. |
| 37 | * Windows. Download `msysgit |
| 38 | <https://code.google.com/p/msysgit/>`_, which includes a minimal |
| 39 | `Cygwin <http://www.cygwin.com/>`_ install. |
| 40 | |
| 41 | 2. Sign up for `Gerrit |
| 42 | <https://ceres-solver-review.googlesource.com/>`_. You will also |
| 43 | need to sign the Contributor License Agreement (CLA) with Google, |
| 44 | which gives Google a royalty-free unlimited license to use your |
| 45 | contributions. You retain copyright. |
| 46 | |
| 47 | 3. Clone the Ceres Solver ``git`` repository from Gerrit. |
| 48 | |
| 49 | .. code-block:: bash |
| 50 | |
| 51 | git clone https://ceres-solver.googlesource.com/ceres-solver |
Sameer Agarwal | 3d87b72 | 2013-02-02 00:49:31 -0800 | [diff] [blame] | 52 | |
| 53 | |
Sameer Agarwal | 480f9b8 | 2013-03-03 20:15:22 -0800 | [diff] [blame] | 54 | 4. Build Ceres, following the instructions in |
| 55 | :ref:`chapter-building`. |
Sameer Agarwal | 3d87b72 | 2013-02-02 00:49:31 -0800 | [diff] [blame] | 56 | |
Sameer Agarwal | 480f9b8 | 2013-03-03 20:15:22 -0800 | [diff] [blame] | 57 | On Mac and Linux, the ``CMake`` build will download and enable |
| 58 | the Gerrit pre-commit hook automatically. This pre-submit hook |
| 59 | creates `Change-Id: ...` lines in your commits. |
| 60 | |
| 61 | If this does not work OR you are on Windows, execute the |
| 62 | following in the root directory of the local ``git`` repository: |
| 63 | |
| 64 | .. code-block:: bash |
| 65 | |
| 66 | curl -o .git/hooks/commit-msg https://ceres-solver-review.googlesource.com/tools/hooks/commit-msg |
| 67 | chmod +x .git/hooks/commit-msg |
| 68 | |
| 69 | 5. Configure your Gerrit password with a ``.netrc`` (Mac and Linux) |
| 70 | or ``_netrc`` (Windows) which allows pushing to Gerrit without |
| 71 | having to enter a very long random password every time: |
| 72 | |
| 73 | * Sign into `http://ceres-solver-review.googlesource.com |
| 74 | <http://ceres-solver-review.googlesource.com>`_. |
| 75 | |
| 76 | * Click ``Settings -> HTTP Password -> Obtain Password``. |
| 77 | |
| 78 | * (maybe) Select an account for multi-login. This should be the |
| 79 | same as your Gerrit login. |
| 80 | |
| 81 | * Click ``Allow access`` when the page requests access to your |
| 82 | ``git`` repositories. |
| 83 | |
| 84 | * Copy the contents of the ``netrc`` into the clipboard. |
| 85 | |
| 86 | - On Mac and Linux, paste the contents into ``~/.netrc``. |
| 87 | |
| 88 | - On Windows, by default users do not have a ``%HOME%`` |
| 89 | setting. |
Sameer Agarwal | e2e857a | 2013-02-04 19:40:45 -0800 | [diff] [blame] | 90 | |
| 91 | |
Sameer Agarwal | 480f9b8 | 2013-03-03 20:15:22 -0800 | [diff] [blame] | 92 | Executing ``setx HOME %USERPROFILE%`` in a terminal will set up |
| 93 | the ``%HOME%`` environment variable persistently, and is used |
| 94 | by ``git`` to find ``%HOME%\_netrc``. |
Sameer Agarwal | 3d87b72 | 2013-02-02 00:49:31 -0800 | [diff] [blame] | 95 | |
Sameer Agarwal | 480f9b8 | 2013-03-03 20:15:22 -0800 | [diff] [blame] | 96 | Then, create a new text file named ``_netrc`` and put it in |
| 97 | e.g. ``C:\Users\username`` where ``username`` is your user |
| 98 | name. |
| 99 | |
| 100 | |
| 101 | Submitting a change to Ceres Solver |
| 102 | =================================== |
| 103 | |
| 104 | 1. Make your changes against master or whatever branch you |
| 105 | like. Commit your changes as one patch. When you commit, the Gerrit |
| 106 | hook will add a `Change-Id:` line as the last line of the commit. |
| 107 | |
| 108 | 2. Push your changes to the Ceres Gerrit instance: |
| 109 | |
| 110 | .. code-block:: bash |
| 111 | |
| 112 | git push origin HEAD:refs/for/master |
| 113 | |
| 114 | When the push succeeds, the console will display a URL showing the |
| 115 | address of the review. Go to the URL and add reviewers; typically |
| 116 | this is Sameer or Keir at this point. |
| 117 | |
| 118 | 3. Wait for a review. |
| 119 | |
| 120 | 4. Once review comments come in, address them. Please reply to each |
| 121 | comment in Gerrit, which makes the re-review process easier. After |
| 122 | modifying the code in your ``git`` instance, *don't make a new |
| 123 | commit*. Instead, update the last commit using a command like the |
| 124 | following: |
| 125 | |
| 126 | .. code-block:: bash |
| 127 | |
| 128 | git commit --amend -a |
| 129 | |
| 130 | This will update the last commit, so that it has both the original |
| 131 | patch and your updates as a single commit. You will have a chance |
| 132 | to edit the commit message as well. Push the new commit to Gerrit |
| 133 | as before. |
| 134 | |
| 135 | Gerrit will use the ``Change-Id:`` to match the previous commit |
| 136 | with the new one. The review interface retains your original patch, |
| 137 | but also shows the new patch. |
| 138 | |
| 139 | Publish your responses to the comments, and wait for a new round |
| 140 | of reviews. |