blob: 3ef8629e1771d2a69ef523bad9f87fab182d9378 [file] [log] [blame]
Austin Schuh70cc9552019-01-21 19:46:48 -08001.. _chapter-contributing:
2
3============
4Contributing
5============
6
7We welcome contributions to Ceres, whether they are new features, bug
8fixes or tests. The Ceres `mailing
9<http://groups.google.com/group/ceres-solver>`_ list is the best place
10for all development related discussions. Please consider joining
11it. If you have ideas on how you would like to contribute to Ceres, it
12is a good idea to let us know on the mailing list before you start
13development. We may have suggestions that will save effort when trying
14to merge your work into the main branch. If you are looking for ideas,
15please let us know about your interest and skills and we will be happy
16to make a suggestion or three.
17
18We follow Google's `C++ Style Guide
19<https://google.github.io/styleguide/cppguide.html>`_ and
20use `git <http://git-scm.com/>`_ for version control. We use the
21`Gerrit <https://ceres-solver-review.googlesource.com/>`_ to collaborate and
22review changes to Ceres. Gerrit enables pre-commit reviews so that
23Ceres can maintain a linear history with clean, reviewed commits, and
24no merges.
25
26We now describe how to set up your development environment and submit
27a change list for review via Gerrit.
28
29Setting up your Environment
30===========================
31
321. Download and configure ``git``.
33
34 * Mac ``brew install git``.
35 * Linux ``sudo apt-get install git``.
36 * Windows. Download `msysgit
37 <https://code.google.com/p/msysgit/>`_, which includes a minimal
38 `Cygwin <http://www.cygwin.com/>`_ install.
39
402. Sign up for `Gerrit
41 <https://ceres-solver-review.googlesource.com/>`_. You will also need to
42 `sign the Contributor License Agreement (CLA)
43 <https://opensource.google.com/docs/cla/#sign>`_ with Google, which gives
44 Google a royalty-free unlimited license to use your contributions. You
45 retain copyright.
46
473. Clone the Ceres Solver ``git`` repository from Gerrit.
48
49 .. code-block:: bash
50
51 git clone https://ceres-solver.googlesource.com/ceres-solver
52
53
544. Build Ceres, following the instructions in
55 :ref:`chapter-installation`.
56
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
695. Configure your Gerrit password with a ``.gitcookies`` which allows pushing
70 to Gerrit without having to enter a very long random password every time:
71
72 * Sign into `http://ceres-solver-review.googlesource.com
73 <http://ceres-solver-review.googlesource.com>`_.
74
75 * Click ``Settings -> HTTP Credentials -> Obtain Password``.
76
77 * (maybe) Select an account for multi-login. This should be the
78 same as your Gerrit login.
79
80 * Click ``Allow access`` when the page requests access to your
81 ``git`` repositories.
82
83 * Follow the instructions from Gerrit to create a ``.gitcookies`` file on
84 your system, either in ``$HOME/.gitcookies`` (Mac and Linux) or
85 ``%USERPROFILE%\.gitcookies`` (Windows). Note that for Windows, please get
86 a recent `Git for Windows <https://git-scm.com/download/win>`_ install to
87 enable automatic lookup in the ``%USERPROFILE%\.gitcookies``.
88
89Submitting a change
90===================
91
921. Make your changes against master or whatever branch you
93 like. Commit your changes as one patch. When you commit, the Gerrit
94 hook will add a `Change-Id:` line as the last line of the commit.
95
96 Make sure that your commit message is formatted in the `50/72 style
97 <http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_.
98
992. Push your changes to the Ceres Gerrit instance:
100
101 .. code-block:: bash
102
103 git push origin HEAD:refs/for/master
104
105 When the push succeeds, the console will display a URL showing the
106 address of the review. Go to the URL and add at least one of the
107 maintainers (Sameer Agarwal, Keir Mierle, Alex Stewart or William
108 Rucklidge) as reviewers.
109
1103. Wait for a review.
111
1124. Once review comments come in, address them. Please reply to each
113 comment in Gerrit, which makes the re-review process easier. After
114 modifying the code in your ``git`` instance, *don't make a new
115 commit*. Instead, update the last commit using a command like the
116 following:
117
118 .. code-block:: bash
119
120 git commit --amend -a
121
122 This will update the last commit, so that it has both the original
123 patch and your updates as a single commit. You will have a chance
124 to edit the commit message as well. Push the new commit to Gerrit
125 as before.
126
127 Gerrit will use the ``Change-Id:`` to match the previous commit
128 with the new one. The review interface retains your original patch,
129 but also shows the new patch.
130
131 Publish your responses to the comments, and wait for a new round
132 of reviews.