blob: 8b5514c578694f6546e7eb3760c75379faa81567 [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.
57
Toby Huangba5bbb42019-09-04 23:23:0758## 9. Commit your changes
Toby Huang5105f812019-08-08 23:47:5759
60Run `git commit`. Here are some
61[tips for writing good commit messages][uploading-a-change-for-review].
62
Toby Huangba5bbb42019-09-04 23:23:0763## 10. Squash your commits
64
65If you have many commits on your current branch, and you want to avoid some
66nasty commit-by-commit merge conflicts in the next step, it is recommended to
67squash your commits into a single commit. This is done by running `git rebase -i
68origin/master`. You should see a list of commits, each commit starting with the
69word "pick". Make sure the first commit says "pick" and change the rest from
70"pick" to "squash". This will squash each commit into the previous commit,
71which will continue until each commit is squashed into the first commit.
72
73## 11. Rebase your local repository
Toby Huang5105f812019-08-08 23:47:5774
75Run `git rebase-update`. This command updates all of your local branches with
76remote changes that have landed since you started development work, which
77could've been a while ago. It also deletes any branches that match the remote
78repository, such as after the CL associated with that branch had merged. You
79may run into rebase conflicts which should be manually fixed before proceeding
80with `git rebase --continue`. Rebasing prevents unintended changes from creeping
81into your CL.
82
83Note that rebasing has the potential to break your build, so you might want to
84try re-building afterwards.
85
Toby Huangba5bbb42019-09-04 23:23:0786## 12. Upload the CL to Gerrit
Toby Huang5105f812019-08-08 23:47:5787
88Run `git cl upload`. Some useful options include:
89
90* `--cq-dry-run` (or `-d`) will set the patchset to do a CQ Dry Run.
91* `-r <chromium_username>` will add reviewers.
92* `-b <bug_number>` automatically populates the bug reference line of the commit
93message.
94
Toby Huangba5bbb42019-09-04 23:23:0795## 13. Check the CL again in Gerrit
Toby Huang5105f812019-08-08 23:47:5796
97Run `git cl web` to go to the Gerrit URL associated with the current branch.
98Open the latest patch set and verify that all of the uploaded files are
99correct. Click `Expand All` to check over all of the individual line-by-line
100changes again.
101
Toby Huangba5bbb42019-09-04 23:23:07102## 14. Make sure all auto-regression tests pass
Toby Huang5105f812019-08-08 23:47:57103
104Click `CQ Dry Run`. Fix any errors because otherwise the CL won't pass the
105commit queue (CQ) checks. Consider waiting for the CQ Dry Run to pass before
106notifying your reviewers, in case the results require major changes in your CL.
107
Toby Huangba5bbb42019-09-04 23:23:07108## 15. Add reviewers to review your code
Toby Huang5105f812019-08-08 23:47:57109
110Click `Find Owners` or run `git cl owners` to find file owners to review your
111code and instruct them about which parts you want them to focus on. Add anyone
112else you think should review your code. For your CL to land, you need an
113approval from an owner for each file you've changed, unless you are an owner of
114some files, in which case you don't need separate owner approval for those
115files.
116
Toby Huangba5bbb42019-09-04 23:23:07117## 16. Implement feedback from your reviewers
Toby Huang5105f812019-08-08 23:47:57118
119Then go through this commit checklist again. Reply to all comments from the
120reviewers on Gerrit and mark all resolved issues as resolved (clicking `Done` or
121`Ack` will do this automatically). Click `Reply` to ensure that your reviewers
122receive a notification. Doing this signals that your CL is ready for review
123again, since the assumption is that your CL is not ready for review until you
124hit reply.
125
Toby Huangba5bbb42019-09-04 23:23:07126## 17. Land your CL
Toby Huang5105f812019-08-08 23:47:57127
128Once you have obtained a Looks Good To Me (LGTM), which is reflected by a
129Code-Review+1 in Gerrit, from at least one owner for each file, then you have
130the minimum prerequisite to land your changes. It may be helpful to wait for all
131of your reviewers to approve your changes as well, even if they're not owners.
132Click `Submit to CQ` to try your change in the commit queue (CQ), which will
133land it if successful.
134
135After your CL is landed, you can use `git rebase-update` or `git cl archive` to
136clean up your local branches.
137
138[//]: # (the reference link section should be alphabetically sorted)
139[contributing]: contributing.md
140[uploading-a-change-for-review]: contributing.md#Uploading-a-change-for-review