Contributing¶
We welcome contributions to Ceres, whether they are new features, bug fixes, or tests. The Ceres mailing list is the best place for development discussions. If you plan to contribute a new feature or significant change, please post your proposal on the mailing list before starting development; early feedback often saves effort during code review. If you are looking for a project, tell us about your interests and background on the mailing list and we will be glad to suggest open problems.
We follow Google’s C++ Style Guide and use git for version control. Code review takes place on Gerrit, which enables pre-commit review so that Ceres maintains a linear history of clean, reviewed commits without merge commits.
The sections below describe how to set up your development environment and submit a change list for review on Gerrit.
Setting up Your Environment¶
Download and configure
git:macOS:
brew install gitLinux:
sudo apt-get install gitWindows: Download Git for Windows.
Sign up for Gerrit and sign the Google Contributor License Agreement (CLA), which grants Google a royalty-free, unlimited license to use your contributions while you retain copyright.
Clone the Ceres Solver
gitrepository from Gerrit:git clone https://ceres-solver.googlesource.com/ceres-solver
Build Ceres following the instructions in Installation.
On macOS and Linux, the
CMakebuild automatically downloads and installs the Gerritcommit-msghook, which appends aChange-Id: ...line to each commit message.If the hook is not installed automatically, or if you are on Windows, run the following commands in the root directory of your local
gitrepository:curl -o .git/hooks/commit-msg https://ceres-solver-review.googlesource.com/tools/hooks/commit-msg chmod +x .git/hooks/commit-msg
Configure a
.gitcookiesfile so that you can push to Gerrit without entering a generated password each time:Sign in to https://ceres-solver-review.googlesource.com.
Click
Settings -> HTTP Credentials -> Obtain Password.If prompted by multi-login, select the account associated with your Gerrit login.
Click
Allow accesswhen prompted to grant access to yourgitrepositories.Follow the instructions on the page to create a
.gitcookiesfile in$HOME/.gitcookies(macOS and Linux) or%USERPROFILE%\.gitcookies(Windows). On Windows, use a recent release of Git for Windows so that%USERPROFILE%\.gitcookiesis detected automatically.
Install
clang-format:macOS:
brew install clang-formatLinux:
sudo apt-get install clang-formatWindows: Install
clang-formatvia Visual Studio, LLVM, or npm.
Format all modified source files before committing by running
clang-format -i FILENAME, executing./scripts/format_all.sh, or configuring your editor to runclang-formaton save.
Submitting a Change¶
Make your changes against
master(or a local branch) and format them withclang-format. Commit your changes as a single logical patch; the Gerrit hook will append aChange-Id:footer to the commit message.Format your commit message in the standard 50/72 style.
Push your commit to Gerrit for review:
git push origin HEAD:refs/for/master
When the push succeeds,
gitprints the URL of the Gerrit review. Open that URL and add at least one maintainer (Sameer Agarwal, Keir Mierle, Alex Stewart, William Rucklidge, or Sergiu Deitsch) as a reviewer.Wait for review feedback.
Address any review comments and reply to each comment thread in Gerrit. Instead of creating a second commit, amend your existing commit so that the
Change-Id:line is preserved:git commit --amend -a
Push the amended commit to
HEAD:refs/for/masteragain. Gerrit uses theChange-Id:footer to attach the new patch set to the existing review while preserving earlier patch sets for comparison. Publish your replies on Gerrit to notify the reviewers.