blob: 7e9fa367ae6e9a646715e960f65bc4abced24e45 [file] [log] [blame] [view]
Toby Huang5105f812019-08-08 23:47:571# Commit Checklist for Chromium Workflow
2
Toby Huange43e5d682019-10-08 21:26:073Here is a helpful checklist to go through before uploading change lists (CLs) on
4Gerrit, which is the code review platform for the Chromium project. This
5checklist is designed to be streamlined. See
6[contributing to Chromium][contributing] for a more thorough reference. The
7intended audience is software engineers who are unfamiliar with contributing to
8the Chromium project.
Toby Huang5105f812019-08-08 23:47:579
10[TOC]
11
12## 1. Create a new branch
13
14You should create a new branch before starting any development work. It's
15helpful to branch early and to branch often in Git.
16
17 git new-branch <branch_name>
18
19which is equivalent to
20
21 git checkout -b <branch_name> --track origin/master
22
Toby Huangba5bbb42019-09-04 23:23:0723## 2. Make your changes
24
25Do your thing. There's no further advice here about how to write or fix code.
26
27## 3. Make sure the code builds correctly
Toby Huang5105f812019-08-08 23:47:5728
29After making your changes, check that common targets build correctly:
30
31* chrome (for Linux, ChromeOS, etc.)
32* unit_tests
33* browser_tests
34
35It's easy to inadvertently break one of the other builds you're not currently
36working on without realizing it. Even though the Commit Queue should catch any
37build errors, checking locally first can save you some time since the CQ Dry Run
38can take a while.
39
Toby Huangba5bbb42019-09-04 23:23:0740## 4. Test your changes
Toby Huang5105f812019-08-08 23:47:5741
42Make sure you hit every code path you changed.
43
Toby Huangba5bbb42019-09-04 23:23:0744## 5. Write unit or browser tests for any new code
Toby Huang5105f812019-08-08 23:47:5745
46Consider automating any manual testing you did in the previous step.
47
Toby Huangba5bbb42019-09-04 23:23:0748## 6. Ensure the code is formatted nicely
Toby Huang5105f812019-08-08 23:47:5749
50Run `git cl format --js`. The `--js` option also formats JavaScript changes.
51
Toby Huangba5bbb42019-09-04 23:23:0752## 7. Check over your changes
Toby Huang5105f812019-08-08 23:47:5753
Toby Huange43e5d682019-10-08 21:26:0754Run `git upstream-diff` to check over all of the changes you've made from the
55most recent checkpoint on the remote repository.
Toby Huang5105f812019-08-08 23:47:5756
Toby Huangba5bbb42019-09-04 23:23:0757## 8. Stage relevant files for commit
Toby Huang5105f812019-08-08 23:47:5758
59Run `git add <path_to_file>` for all of the relevant files you've modified.
Toby Huange43e5d682019-10-08 21:26:0760Unlike other version-control systems such as svn, you have to specifically `git
61add` the files you want to commit before calling `git commit`.
Toby Huang5105f812019-08-08 23:47:5762
Toby Huangba5bbb42019-09-04 23:23:0763## 9. Commit your changes
Toby Huang5105f812019-08-08 23:47:5764
65Run `git commit`. Here are some
66[tips for writing good commit messages][uploading-a-change-for-review].
67
Toby Huangba5bbb42019-09-04 23:23:0768## 10. Squash your commits
69
70If you have many commits on your current branch, and you want to avoid some
71nasty commit-by-commit merge conflicts in the next step, it is recommended to
72squash your commits into a single commit. This is done by running `git rebase -i
Toby Huange43e5d682019-10-08 21:26:0773<upstream-branch>`. The upstream branch is usually origin/master, but check `git
74branch -vv` to make sure. After running the git rebase command, you should see a
75list of commits, each commit starting with the word "pick". Make sure the first
76commit says "pick" and change the rest from "pick" to "squash". This will squash
77each commit into the previous commit, which will continue until each commit is
78squashed into the first commit.
Toby Huangba5bbb42019-09-04 23:23:0779
80## 11. Rebase your local repository
Toby Huang5105f812019-08-08 23:47:5781
82Run `git rebase-update`. This command updates all of your local branches with
83remote changes that have landed since you started development work, which
84could've been a while ago. It also deletes any branches that match the remote
Toby Huange43e5d682019-10-08 21:26:0785repository, such as after the CL associated with that branch had merged. You may
86run into rebase conflicts which should be manually fixed before proceeding with
87`git rebase --continue`. Rebasing prevents unintended changes from creeping into
88your CL.
Toby Huang5105f812019-08-08 23:47:5789
90Note that rebasing has the potential to break your build, so you might want to
91try re-building afterwards.
92
Toby Huangba5bbb42019-09-04 23:23:0793## 12. Upload the CL to Gerrit
Toby Huang5105f812019-08-08 23:47:5794
95Run `git cl upload`. Some useful options include:
96
Toby Huange43e5d682019-10-08 21:26:0797* `--cq-dry-run` (or `-d`) will set the patchset to do a CQ Dry Run.
98* `-r <chromium_username>` will add reviewers.
99* `-b <bug_number>` automatically populates the bug reference line of the
100 commit message.
Toby Huang5105f812019-08-08 23:47:57101
Toby Huangba5bbb42019-09-04 23:23:07102## 13. Check the CL again in Gerrit
Toby Huang5105f812019-08-08 23:47:57103
104Run `git cl web` to go to the Gerrit URL associated with the current branch.
Toby Huange43e5d682019-10-08 21:26:07105Open the latest patch set and verify that all of the uploaded files are correct.
106Click `Expand All` to check over all of the individual line-by-line changes
107again.
Toby Huang5105f812019-08-08 23:47:57108
Toby Huangba5bbb42019-09-04 23:23:07109## 14. Make sure all auto-regression tests pass
Toby Huang5105f812019-08-08 23:47:57110
111Click `CQ Dry Run`. Fix any errors because otherwise the CL won't pass the
112commit queue (CQ) checks. Consider waiting for the CQ Dry Run to pass before
113notifying your reviewers, in case the results require major changes in your CL.
114
Toby Huangba5bbb42019-09-04 23:23:07115## 15. Add reviewers to review your code
Toby Huang5105f812019-08-08 23:47:57116
117Click `Find Owners` or run `git cl owners` to find file owners to review your
118code and instruct them about which parts you want them to focus on. Add anyone
Toby Huange43e5d682019-10-08 21:26:07119else you think should review your code. The blame functionality in Code Search
120is a good way to identify reviewers who may be familiar with the parts of code
121your CL touches. For your CL to land, you need an approval from an owner for
122each file you've changed, unless you are an owner of some files, in which case
123you don't need separate owner approval for those files.
Toby Huang5105f812019-08-08 23:47:57124
Toby Huangba5bbb42019-09-04 23:23:07125## 16. Implement feedback from your reviewers
Toby Huang5105f812019-08-08 23:47:57126
127Then go through this commit checklist again. Reply to all comments from the
128reviewers on Gerrit and mark all resolved issues as resolved (clicking `Done` or
129`Ack` will do this automatically). Click `Reply` to ensure that your reviewers
130receive a notification. Doing this signals that your CL is ready for review
131again, since the assumption is that your CL is not ready for review until you
132hit reply.
133
Toby Huangba5bbb42019-09-04 23:23:07134## 17. Land your CL
Toby Huang5105f812019-08-08 23:47:57135
136Once you have obtained a Looks Good To Me (LGTM), which is reflected by a
137Code-Review+1 in Gerrit, from at least one owner for each file, then you have
138the minimum prerequisite to land your changes. It may be helpful to wait for all
139of your reviewers to approve your changes as well, even if they're not owners.
140Click `Submit to CQ` to try your change in the commit queue (CQ), which will
141land it if successful.
142
143After your CL is landed, you can use `git rebase-update` or `git cl archive` to
144clean up your local branches.
145
146[//]: # (the reference link section should be alphabetically sorted)
147[contributing]: contributing.md
148[uploading-a-change-for-review]: contributing.md#Uploading-a-change-for-review