blob: 20fe34d47c6e3486cd463ee254188068c4c84080 [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
Sameer Agarwal5d7c1952013-05-07 12:47:51 -070021use `git <http://git-scm.com/>`_ for version control. We use the
Sameer Agarwala6b76c72013-05-09 14:58:49 -070022`Gerrit <https://ceres-solver-review.googlesource.com/>`_ to collaborate and
Sameer Agarwal5d7c1952013-05-07 12:47:51 -070023review changes to Ceres. Gerrit enables pre-commit reviews so that
Sameer Agarwal480f9b82013-03-03 20:15:22 -080024Ceres can maintain a linear history with clean, reviewed commits, and
25no merges.
26
27We now describe how to set up your development environment and submit
28a change list for review via Gerrit.
29
30Setting up your Development Environment
31=======================================
32
331. 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
412. 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
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
Sameer Agarwal3d87b722013-02-02 00:49:31 -080052
53
Sameer Agarwal480f9b82013-03-03 20:15:22 -0800544. Build Ceres, following the instructions in
55 :ref:`chapter-building`.
Sameer Agarwal3d87b722013-02-02 00:49:31 -080056
Sameer Agarwal480f9b82013-03-03 20:15:22 -080057 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 ``.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 Agarwale2e857a2013-02-04 19:40:45 -080090
91
Sameer Agarwal480f9b82013-03-03 20:15:22 -080092 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 Agarwal3d87b722013-02-02 00:49:31 -080095
Sameer Agarwal480f9b82013-03-03 20:15:22 -080096 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
101Submitting a change to Ceres Solver
102===================================
103
1041. 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
1082. 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
1183. Wait for a review.
119
1204. 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.