Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 1 | # Commit Checklist for Chromium Workflow |
| 2 | |
| 3 | Here is a helpful checklist to go through before uploading change lists (CLs) |
| 4 | on Gerrit. This checklist is designed to be streamlined. See [contributing to |
| 5 | Chromium][contributing] for a more thorough reference. |
| 6 | |
| 7 | [TOC] |
| 8 | |
| 9 | ## 1. Create a new branch |
| 10 | |
| 11 | You should create a new branch before starting any development work. It's |
| 12 | helpful to branch early and to branch often in Git. |
| 13 | |
| 14 | git new-branch <branch_name> |
| 15 | |
| 16 | which is equivalent to |
| 17 | |
| 18 | git checkout -b <branch_name> --track origin/master |
| 19 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 20 | ## 2. Make your changes |
| 21 | |
| 22 | Do 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 Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 25 | |
| 26 | After making your changes, check that common targets build correctly: |
| 27 | |
| 28 | * chrome (for Linux, ChromeOS, etc.) |
| 29 | * unit_tests |
| 30 | * browser_tests |
| 31 | |
| 32 | It's easy to inadvertently break one of the other builds you're not currently |
| 33 | working on without realizing it. Even though the Commit Queue should catch any |
| 34 | build errors, checking locally first can save you some time since the CQ Dry Run |
| 35 | can take a while. |
| 36 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 37 | ## 4. Test your changes |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 38 | |
| 39 | Make sure you hit every code path you changed. |
| 40 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 41 | ## 5. Write unit or browser tests for any new code |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 42 | |
| 43 | Consider automating any manual testing you did in the previous step. |
| 44 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 45 | ## 6. Ensure the code is formatted nicely |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 46 | |
| 47 | Run `git cl format --js`. The `--js` option also formats JavaScript changes. |
| 48 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 49 | ## 7. Check over your changes |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 50 | |
| 51 | Run `git upstream-diff` to check over all of the changes you've made from |
| 52 | the most recent checkpoint on the remote repository. |
| 53 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 54 | ## 8. Stage relevant files for commit |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 55 | |
| 56 | Run `git add <path_to_file>` for all of the relevant files you've modified. |
Toby Huang | 242a9f54 | 2019-09-13 00:23:23 | [diff] [blame] | 57 | Unlike 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 Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 59 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 60 | ## 9. Commit your changes |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 61 | |
| 62 | Run `git commit`. Here are some |
| 63 | [tips for writing good commit messages][uploading-a-change-for-review]. |
| 64 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 65 | ## 10. Squash your commits |
| 66 | |
| 67 | If you have many commits on your current branch, and you want to avoid some |
| 68 | nasty commit-by-commit merge conflicts in the next step, it is recommended to |
| 69 | squash your commits into a single commit. This is done by running `git rebase -i |
| 70 | origin/master`. You should see a list of commits, each commit starting with the |
| 71 | word "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, |
| 73 | which will continue until each commit is squashed into the first commit. |
| 74 | |
| 75 | ## 11. Rebase your local repository |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 76 | |
| 77 | Run `git rebase-update`. This command updates all of your local branches with |
| 78 | remote changes that have landed since you started development work, which |
| 79 | could've been a while ago. It also deletes any branches that match the remote |
| 80 | repository, such as after the CL associated with that branch had merged. You |
| 81 | may run into rebase conflicts which should be manually fixed before proceeding |
| 82 | with `git rebase --continue`. Rebasing prevents unintended changes from creeping |
| 83 | into your CL. |
| 84 | |
| 85 | Note that rebasing has the potential to break your build, so you might want to |
| 86 | try re-building afterwards. |
| 87 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 88 | ## 12. Upload the CL to Gerrit |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 89 | |
| 90 | Run `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 |
| 95 | message. |
| 96 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 97 | ## 13. Check the CL again in Gerrit |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 98 | |
| 99 | Run `git cl web` to go to the Gerrit URL associated with the current branch. |
| 100 | Open the latest patch set and verify that all of the uploaded files are |
| 101 | correct. Click `Expand All` to check over all of the individual line-by-line |
| 102 | changes again. |
| 103 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 104 | ## 14. Make sure all auto-regression tests pass |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 105 | |
| 106 | Click `CQ Dry Run`. Fix any errors because otherwise the CL won't pass the |
| 107 | commit queue (CQ) checks. Consider waiting for the CQ Dry Run to pass before |
| 108 | notifying your reviewers, in case the results require major changes in your CL. |
| 109 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 110 | ## 15. Add reviewers to review your code |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 111 | |
| 112 | Click `Find Owners` or run `git cl owners` to find file owners to review your |
| 113 | code and instruct them about which parts you want them to focus on. Add anyone |
| 114 | else you think should review your code. For your CL to land, you need an |
| 115 | approval from an owner for each file you've changed, unless you are an owner of |
| 116 | some files, in which case you don't need separate owner approval for those |
| 117 | files. |
| 118 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 119 | ## 16. Implement feedback from your reviewers |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 120 | |
| 121 | Then go through this commit checklist again. Reply to all comments from the |
| 122 | reviewers 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 |
| 124 | receive a notification. Doing this signals that your CL is ready for review |
| 125 | again, since the assumption is that your CL is not ready for review until you |
| 126 | hit reply. |
| 127 | |
Toby Huang | ba5bbb4 | 2019-09-04 23:23:07 | [diff] [blame] | 128 | ## 17. Land your CL |
Toby Huang | 5105f81 | 2019-08-08 23:47:57 | [diff] [blame] | 129 | |
| 130 | Once you have obtained a Looks Good To Me (LGTM), which is reflected by a |
| 131 | Code-Review+1 in Gerrit, from at least one owner for each file, then you have |
| 132 | the minimum prerequisite to land your changes. It may be helpful to wait for all |
| 133 | of your reviewers to approve your changes as well, even if they're not owners. |
| 134 | Click `Submit to CQ` to try your change in the commit queue (CQ), which will |
| 135 | land it if successful. |
| 136 | |
| 137 | After your CL is landed, you can use `git rebase-update` or `git cl archive` to |
| 138 | clean 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 |