blob: b67430adc218c66908c0a1f5095e675024f49939 [file] [log] [blame] [view]
Toby Huang5105f812019-08-08 23:47:571# Commit Checklist for Chromium Workflow
2
3Here is a helpful checklist to go through before uploading change lists (CLs)
4on Gerrit. This checklist is designed to be streamlined. See [contributing to
5Chromium][contributing] for a more thorough reference.
6
7[TOC]
8
9## 1. Create a new branch
10
11You should create a new branch before starting any development work. It's
12helpful to branch early and to branch often in Git.
13
14 git new-branch <branch_name>
15
16which is equivalent to
17
18 git checkout -b <branch_name> --track origin/master
19
Toby Huangba5bbb42019-09-04 23:23:0720## 2. Make your changes
21
22Do your thing. There's no further advice here about how to write or fix code.
23
24## 3. Make sure the code builds correctly
Toby Huang5105f812019-08-08 23:47:5725
26After making your changes, check that common targets build correctly:
27
28* chrome (for Linux, ChromeOS, etc.)
29* unit_tests
30* browser_tests
31
32It's easy to inadvertently break one of the other builds you're not currently
33working on without realizing it. Even though the Commit Queue should catch any
34build errors, checking locally first can save you some time since the CQ Dry Run
35can take a while.
36
Toby Huangba5bbb42019-09-04 23:23:0737## 4. Test your changes
Toby Huang5105f812019-08-08 23:47:5738
39Make sure you hit every code path you changed.
40
Toby Huangba5bbb42019-09-04 23:23:0741## 5. Write unit or browser tests for any new code
Toby Huang5105f812019-08-08 23:47:5742
43Consider automating any manual testing you did in the previous step.
44
Toby Huangba5bbb42019-09-04 23:23:0745## 6. Ensure the code is formatted nicely
Toby Huang5105f812019-08-08 23:47:5746
47Run `git cl format --js`. The `--js` option also formats JavaScript changes.
48
Toby Huangba5bbb42019-09-04 23:23:0749## 7. Check over your changes
Toby Huang5105f812019-08-08 23:47:5750
51Run `git upstream-diff` to check over all of the changes you've made from
52the most recent checkpoint on the remote repository.
53
Toby Huangba5bbb42019-09-04 23:23:0754## 8. Stage relevant files for commit
Toby Huang5105f812019-08-08 23:47:5755
56Run `git add <path_to_file>` for all of the relevant files you've modified.
Toby Huang242a9f542019-09-13 00:23:2357Unlike other version-control systems such as svn, you have to specifically
58`git add` the files you want to commit before calling `git commit`.
Toby Huang5105f812019-08-08 23:47:5759
Toby Huangba5bbb42019-09-04 23:23:0760## 9. Commit your changes
Toby Huang5105f812019-08-08 23:47:5761
62Run `git commit`. Here are some
63[tips for writing good commit messages][uploading-a-change-for-review].
64
Toby Huangba5bbb42019-09-04 23:23:0765## 10. Squash your commits
66
67If you have many commits on your current branch, and you want to avoid some
68nasty commit-by-commit merge conflicts in the next step, it is recommended to
69squash your commits into a single commit. This is done by running `git rebase -i
70origin/master`. You should see a list of commits, each commit starting with the
71word "pick". Make sure the first commit says "pick" and change the rest from
72"pick" to "squash". This will squash each commit into the previous commit,
73which will continue until each commit is squashed into the first commit.
74
75## 11. Rebase your local repository
Toby Huang5105f812019-08-08 23:47:5776
77Run `git rebase-update`. This command updates all of your local branches with
78remote changes that have landed since you started development work, which
79could've been a while ago. It also deletes any branches that match the remote
80repository, such as after the CL associated with that branch had merged. You
81may run into rebase conflicts which should be manually fixed before proceeding
82with `git rebase --continue`. Rebasing prevents unintended changes from creeping
83into your CL.
84
85Note that rebasing has the potential to break your build, so you might want to
86try re-building afterwards.
87
Toby Huangba5bbb42019-09-04 23:23:0788## 12. Upload the CL to Gerrit
Toby Huang5105f812019-08-08 23:47:5789
90Run `git cl upload`. Some useful options include:
91
92* `--cq-dry-run` (or `-d`) will set the patchset to do a CQ Dry Run.
93* `-r <chromium_username>` will add reviewers.
94* `-b <bug_number>` automatically populates the bug reference line of the commit
95message.
96
Toby Huangba5bbb42019-09-04 23:23:0797## 13. Check the CL again in Gerrit
Toby Huang5105f812019-08-08 23:47:5798
99Run `git cl web` to go to the Gerrit URL associated with the current branch.
100Open the latest patch set and verify that all of the uploaded files are
101correct. Click `Expand All` to check over all of the individual line-by-line
102changes again.
103
Toby Huangba5bbb42019-09-04 23:23:07104## 14. Make sure all auto-regression tests pass
Toby Huang5105f812019-08-08 23:47:57105
106Click `CQ Dry Run`. Fix any errors because otherwise the CL won't pass the
107commit queue (CQ) checks. Consider waiting for the CQ Dry Run to pass before
108notifying your reviewers, in case the results require major changes in your CL.
109
Toby Huangba5bbb42019-09-04 23:23:07110## 15. Add reviewers to review your code
Toby Huang5105f812019-08-08 23:47:57111
112Click `Find Owners` or run `git cl owners` to find file owners to review your
113code and instruct them about which parts you want them to focus on. Add anyone
114else you think should review your code. For your CL to land, you need an
115approval from an owner for each file you've changed, unless you are an owner of
116some files, in which case you don't need separate owner approval for those
117files.
118
Toby Huangba5bbb42019-09-04 23:23:07119## 16. Implement feedback from your reviewers
Toby Huang5105f812019-08-08 23:47:57120
121Then go through this commit checklist again. Reply to all comments from the
122reviewers on Gerrit and mark all resolved issues as resolved (clicking `Done` or
123`Ack` will do this automatically). Click `Reply` to ensure that your reviewers
124receive a notification. Doing this signals that your CL is ready for review
125again, since the assumption is that your CL is not ready for review until you
126hit reply.
127
Toby Huangba5bbb42019-09-04 23:23:07128## 17. Land your CL
Toby Huang5105f812019-08-08 23:47:57129
130Once you have obtained a Looks Good To Me (LGTM), which is reflected by a
131Code-Review+1 in Gerrit, from at least one owner for each file, then you have
132the minimum prerequisite to land your changes. It may be helpful to wait for all
133of your reviewers to approve your changes as well, even if they're not owners.
134Click `Submit to CQ` to try your change in the commit queue (CQ), which will
135land it if successful.
136
137After your CL is landed, you can use `git rebase-update` or `git cl archive` to
138clean up your local branches.
139
140[//]: # (the reference link section should be alphabetically sorted)
141[contributing]: contributing.md
142[uploading-a-change-for-review]: contributing.md#Uploading-a-change-for-review