contributing.rst 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. .. _chapter-contributing:
  2. ============
  3. Contributing
  4. ============
  5. We welcome contributions to Ceres, whether they are new features, bug
  6. fixes or tests. The Ceres `mailing
  7. <http://groups.google.com/group/ceres-solver>`_ list is the best place
  8. for all development related discussions. Please consider joining
  9. it. If you have ideas on how you would like to contribute to Ceres, it
  10. is a good idea to let us know on the mailing list before you start
  11. development. We may have suggestions that will save effort when trying
  12. to merge your work into the main branch. If you are looking for ideas,
  13. please let us know about your interest and skills and we will be happy
  14. to make a suggestion or three.
  15. We follow Google's `C++ Style Guide
  16. <https://google.github.io/styleguide/cppguide.html>`_ and
  17. use `git <http://git-scm.com/>`_ for version control. We use the
  18. `Gerrit <https://ceres-solver-review.googlesource.com/>`_ to collaborate and
  19. review changes to Ceres. Gerrit enables pre-commit reviews so that
  20. Ceres can maintain a linear history with clean, reviewed commits, and
  21. no merges.
  22. We now describe how to set up your development environment and submit
  23. a change list for review via Gerrit.
  24. Setting up your Environment
  25. ===========================
  26. 1. Download and configure ``git``.
  27. * Mac ``brew install git``.
  28. * Linux ``sudo apt-get install git``.
  29. * Windows. Download `msysgit
  30. <https://code.google.com/p/msysgit/>`_, which includes a minimal
  31. `Cygwin <http://www.cygwin.com/>`_ install.
  32. 2. Sign up for `Gerrit
  33. <https://ceres-solver-review.googlesource.com/>`_. You will also need to
  34. `sign the Contributor License Agreement (CLA)
  35. <https://opensource.google.com/docs/cla/#sign>`_ with Google, which gives
  36. Google a royalty-free unlimited license to use your contributions. You
  37. retain copyright.
  38. 3. Clone the Ceres Solver ``git`` repository from Gerrit.
  39. .. code-block:: bash
  40. git clone https://ceres-solver.googlesource.com/ceres-solver
  41. 4. Build Ceres, following the instructions in
  42. :ref:`chapter-installation`.
  43. On Mac and Linux, the ``CMake`` build will download and enable
  44. the Gerrit pre-commit hook automatically. This pre-submit hook
  45. creates ``Change-Id: ...`` lines in your commits.
  46. If this does not work OR you are on Windows, execute the
  47. following in the root directory of the local ``git`` repository:
  48. .. code-block:: bash
  49. curl -o .git/hooks/commit-msg https://ceres-solver-review.googlesource.com/tools/hooks/commit-msg
  50. chmod +x .git/hooks/commit-msg
  51. 5. Configure your Gerrit password with a ``.gitcookies`` which allows pushing
  52. to Gerrit without having to enter a very long random password every time:
  53. * Sign into `http://ceres-solver-review.googlesource.com
  54. <http://ceres-solver-review.googlesource.com>`_.
  55. * Click ``Settings -> HTTP Credentials -> Obtain Password``.
  56. * (maybe) Select an account for multi-login. This should be the
  57. same as your Gerrit login.
  58. * Click ``Allow access`` when the page requests access to your
  59. ``git`` repositories.
  60. * Follow the instructions from Gerrit to create a ``.gitcookies`` file on
  61. your system, either in ``$HOME/.gitcookies`` (Mac and Linux) or
  62. ``%USERPROFILE%\.gitcookies`` (Windows). Note that for Windows, please get
  63. a recent `Git for Windows <https://git-scm.com/download/win>`_ install to
  64. enable automatic lookup in the ``%USERPROFILE%\.gitcookies``.
  65. 6. Install ``clang-format``.
  66. * Mac ``brew install clang-format``.
  67. * Linux ``sudo apt-get install clang-format``.
  68. * Windows. You can get clang-format with `clang or stand-alone via
  69. npm <https://superuser.com/a/1505297/1141693>`_.
  70. You can ensure all sources files are correctly formatted before
  71. committing by manually running ``clang-format -i FILENAME``, by
  72. running the script ``./scripts/format_all.sh``, or by configuring
  73. your editor to format upon saving.
  74. Submitting a change
  75. ===================
  76. 1. Make your changes against master or whatever branch you
  77. like. Ensure that the changes are formatted according to
  78. ``clang-format``. Commit your changes as one patch. When you
  79. commit, the Gerrit hook will add a ``Change-Id:`` line as the last
  80. line of the commit.
  81. Make sure that your commit message is formatted in the `50/72 style
  82. <http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_.
  83. 2. Push your changes to the Ceres Gerrit instance:
  84. .. code-block:: bash
  85. git push origin HEAD:refs/for/master
  86. When the push succeeds, the console will display a URL showing the
  87. address of the review. Go to the URL and add at least one of the
  88. maintainers (Sameer Agarwal, Keir Mierle, Alex Stewart, William
  89. Rucklidge or Sergiu Deitsch) as reviewers.
  90. 3. Wait for a review.
  91. 4. Once review comments come in, address them. Please reply to each
  92. comment in Gerrit, which makes the re-review process easier. After
  93. modifying the code in your ``git`` instance, *don't make a new
  94. commit*. Instead, update the last commit using a command like the
  95. following:
  96. .. code-block:: bash
  97. git commit --amend -a
  98. This will update the last commit, so that it has both the original
  99. patch and your updates as a single commit. You will have a chance
  100. to edit the commit message as well. Push the new commit to Gerrit
  101. as before.
  102. Gerrit will use the ``Change-Id:`` to match the previous commit
  103. with the new one. The review interface retains your original patch,
  104. but also shows the new patch.
  105. Publish your responses to the comments, and wait for a new round
  106. of reviews.