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