blob: ffa6149fd65f55f146afd8cd0ffc89e59c9bfad1 [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
Toby Huang0a0375c2020-02-21 08:00:288the Chromium project. Feel free to skip steps that are not applicable to the
9patch set you're currently uploading.
Toby Huang5105f812019-08-08 23:47:5710
11[TOC]
12
13## 1. Create a new branch
14
15You should create a new branch before starting any development work. It's
Toby Huang0a0375c2020-02-21 08:00:2816helpful to branch early and to branch often in Git. Use the command
17`git new-branch <branch_name>`. This is equivalent to
18`git checkout -b <branch_name> --track origin/master`.
Toby Huang5105f812019-08-08 23:47:5719
Toby Huang0a0375c2020-02-21 08:00:2820You may also want to set another local branch as the upstream branch. You can do
21that with `git checkout -b <branch_name> --track <upstream_branch>`.
Toby Huang5105f812019-08-08 23:47:5722
Toby Huang5c3c00e2019-10-30 23:29:0523Mark the associated crbug as "started" so that other people know that you have
24started work on the bug. Doing this can avoid duplicated work.
25
Toby Huangba5bbb42019-09-04 23:23:0726## 2. Make your changes
27
28Do your thing. There's no further advice here about how to write or fix code.
29
30## 3. Make sure the code builds correctly
Toby Huang5105f812019-08-08 23:47:5731
32After making your changes, check that common targets build correctly:
33
34* chrome (for Linux, ChromeOS, etc.)
35* unit_tests
36* browser_tests
37
38It's easy to inadvertently break one of the other builds you're not currently
39working on without realizing it. Even though the Commit Queue should catch any
40build errors, checking locally first can save you some time since the CQ Dry Run
41can take a while.
42
Toby Huangba5bbb42019-09-04 23:23:0743## 4. Test your changes
Toby Huang5105f812019-08-08 23:47:5744
45Make sure you hit every code path you changed.
46
Toby Huangba5bbb42019-09-04 23:23:0747## 5. Write unit or browser tests for any new code
Toby Huang5105f812019-08-08 23:47:5748
49Consider automating any manual testing you did in the previous step.
50
Toby Huangba5bbb42019-09-04 23:23:0751## 6. Ensure the code is formatted nicely
Toby Huang5105f812019-08-08 23:47:5752
53Run `git cl format --js`. The `--js` option also formats JavaScript changes.
54
Toby Huang0a0375c2020-02-21 08:00:2855## 7. Review your changes
Toby Huang5105f812019-08-08 23:47:5756
Toby Huang0a0375c2020-02-21 08:00:2857Use `git diff` to review all of the changes you've made from the previous
58commit. Use `git upstream-diff` to review all of the changes you've made
59from the upstream branch. The output from `git upstream-diff` is what will
60be uploaded to Gerrit.
Toby Huang5105f812019-08-08 23:47:5761
Toby Huangba5bbb42019-09-04 23:23:0762## 8. Stage relevant files for commit
Toby Huang5105f812019-08-08 23:47:5763
Toby Huang0a0375c2020-02-21 08:00:2864Run `git add <path_to_file>` for all of the files you've modified that you want
65to include in the CL. Unlike other version-control systems such as svn, you have
66to specifically `git add` the files you want to commit before calling
67`git commit`.
Toby Huang5105f812019-08-08 23:47:5768
Toby Huangba5bbb42019-09-04 23:23:0769## 9. Commit your changes
Toby Huang5105f812019-08-08 23:47:5770
Toby Huang0a0375c2020-02-21 08:00:2871Run `git commit`. Be sure to write a useful commit message. Here are some
72[tips for writing good commit messages][uploading-a-change-for-review]. A
73shortcut for combining steps 8 and 9 is `git commit -a -m <commit_message>`.
Toby Huang5105f812019-08-08 23:47:5774
Toby Huangba5bbb42019-09-04 23:23:0775## 10. Squash your commits
76
77If you have many commits on your current branch, and you want to avoid some
Toby Huang0a0375c2020-02-21 08:00:2878nasty commit-by-commit merge conflicts in the next step, consider collecting all
79your changes into one commit. Run `git rebase -i @{u}`. The `@{u}` is a
80short-hand pointer for the upstream branch, which is usually origin/master.
81After running the `git rebase` command, you should see a list of commits, with
82each commit starting with the word "pick". Make sure the first commit says
83"pick" and change the rest from "pick" to "squash". This will squash each commit
84into the previous commit, which will continue until each commit is squashed into
85the first commit.
Toby Huangba5bbb42019-09-04 23:23:0786
87## 11. Rebase your local repository
Toby Huang5105f812019-08-08 23:47:5788
Toby Huang0a0375c2020-02-21 08:00:2889Rebasing is a neat way to resolve any merge conflict errors on your CL. Run
90`git rebase-update`. This command updates all of your local branches with
Toby Huang5105f812019-08-08 23:47:5791remote changes that have landed since you started development work, which
92could've been a while ago. It also deletes any branches that match the remote
Toby Huang0a0375c2020-02-21 08:00:2893repository, such as after the CL associated with that branch has been merged.
94In summary, `git rebse-update` cleans up your local branches.
Toby Huang5105f812019-08-08 23:47:5795
Toby Huang0a0375c2020-02-21 08:00:2896You may run into rebase conflicts. Fix them manually before proceeding with
97`git rebase --continue`. Note that rebasing has the potential to break your
98build, so you might want to try re-building afterwards.
Toby Huang5105f812019-08-08 23:47:5799
Toby Huangba5bbb42019-09-04 23:23:07100## 12. Upload the CL to Gerrit
Toby Huang5105f812019-08-08 23:47:57101
102Run `git cl upload`. Some useful options include:
103
Toby Huange43e5d682019-10-08 21:26:07104* `--cq-dry-run` (or `-d`) will set the patchset to do a CQ Dry Run.
105* `-r <chromium_username>` will add reviewers.
106* `-b <bug_number>` automatically populates the bug reference line of the
107 commit message.
Toby Huang5105f812019-08-08 23:47:57108
Toby Huangba5bbb42019-09-04 23:23:07109## 13. Check the CL again in Gerrit
Toby Huang5105f812019-08-08 23:47:57110
111Run `git cl web` to go to the Gerrit URL associated with the current branch.
Toby Huange43e5d682019-10-08 21:26:07112Open the latest patch set and verify that all of the uploaded files are correct.
113Click `Expand All` to check over all of the individual line-by-line changes
114again.
Toby Huang5105f812019-08-08 23:47:57115
Toby Huangba5bbb42019-09-04 23:23:07116## 14. Make sure all auto-regression tests pass
Toby Huang5105f812019-08-08 23:47:57117
118Click `CQ Dry Run`. Fix any errors because otherwise the CL won't pass the
119commit queue (CQ) checks. Consider waiting for the CQ Dry Run to pass before
120notifying your reviewers, in case the results require major changes in your CL.
121
Toby Huangba5bbb42019-09-04 23:23:07122## 15. Add reviewers to review your code
Toby Huang5105f812019-08-08 23:47:57123
124Click `Find Owners` or run `git cl owners` to find file owners to review your
125code and instruct them about which parts you want them to focus on. Add anyone
Toby Huange43e5d682019-10-08 21:26:07126else you think should review your code. The blame functionality in Code Search
127is a good way to identify reviewers who may be familiar with the parts of code
128your CL touches. For your CL to land, you need an approval from an owner for
129each file you've changed, unless you are an owner of some files, in which case
130you don't need separate owner approval for those files.
Toby Huang5105f812019-08-08 23:47:57131
Toby Huangba5bbb42019-09-04 23:23:07132## 16. Implement feedback from your reviewers
Toby Huang5105f812019-08-08 23:47:57133
134Then go through this commit checklist again. Reply to all comments from the
135reviewers on Gerrit and mark all resolved issues as resolved (clicking `Done` or
136`Ack` will do this automatically). Click `Reply` to ensure that your reviewers
137receive a notification. Doing this signals that your CL is ready for review
138again, since the assumption is that your CL is not ready for review until you
139hit reply.
140
Toby Huangba5bbb42019-09-04 23:23:07141## 17. Land your CL
Toby Huang5105f812019-08-08 23:47:57142
143Once you have obtained a Looks Good To Me (LGTM), which is reflected by a
144Code-Review+1 in Gerrit, from at least one owner for each file, then you have
145the minimum prerequisite to land your changes. It may be helpful to wait for all
146of your reviewers to approve your changes as well, even if they're not owners.
147Click `Submit to CQ` to try your change in the commit queue (CQ), which will
148land it if successful.
149
Toby Huang5c3c00e2019-10-30 23:29:05150## 18. Cleanup
151
Toby Huang5105f812019-08-08 23:47:57152After your CL is landed, you can use `git rebase-update` or `git cl archive` to
Toby Huang5c3c00e2019-10-30 23:29:05153clean up your local branches. These commands will automatically delete merged
154branches. Mark the associated crbug as "fixed".
Toby Huang5105f812019-08-08 23:47:57155
156[//]: # (the reference link section should be alphabetically sorted)
157[contributing]: contributing.md
158[uploading-a-change-for-review]: contributing.md#Uploading-a-change-for-review