1--- 2title: 'How to submit a patch' 3linkTitle: 'How to submit a patch' 4--- 5 6## Configure git 7 8<!--?prettify lang=sh?--> 9 10 git config --global user.name "Your Name" 11 git config --global user.email [email protected] 12 13## Making changes 14 15First create a branch for your changes: 16 17<!--?prettify lang=sh?--> 18 19 git config branch.autosetuprebase always 20 git checkout -b my_feature origin/main 21 22After making your changes, create a commit 23 24<!--?prettify lang=sh?--> 25 26 git add [file1] [file2] ... 27 git commit 28 29If your branch gets out of date, you will need to update it: 30 31<!--?prettify lang=sh?--> 32 33 git pull 34 python3 tools/git-sync-deps 35 36## Adding a unit test 37 38If you are willing to change Skia codebase, it's nice to add a test at the same 39time. Skia has a simple unittest framework so you can add a case to it. 40 41Test code is located under the 'tests' directory. 42 43See [Writing Unit and Rendering Tests](/docs/dev/testing/tests) for details. 44 45Unit tests are best, but if your change touches rendering and you can't think of 46an automated way to verify the results, consider writing a GM test. Also, if 47your change is in the GPU code, you may not be able to write it as part of the 48standard unit test suite, but there are GPU-specific testing paths you can 49extend. 50 51## Updating BUILD.bazel files 52 53If you added or removed files, you will need to update the `BUILD.bazel` file in the directory 54of those files. Many `BUILD.bazel` files have a list of files that is broken up into two 55[`filegroup`](https://bazel.build/reference/be/general#filegroup) rules using the 56`split_srcs_and_hdrs` macro. You should add the new file names or delete the old ones from these 57file lists. 58 59If your feature will be conditionally enabled (e.g. like the GPU backends or image codecs), you 60may need to add or modify 61[`select`](https://bazel.build/reference/be/common-definitions#configurable-attributes) statements 62to achieve that goal. Look at existing rules for examples of this. 63 64## Submitting a patch 65 66For your code to be accepted into the codebase, you must complete the 67[Individual Contributor License Agreement](http://code.google.com/legal/individual-cla-v1.0.html). 68You can do this online, and it only takes a minute. If you are contributing on 69behalf of a corporation, you must fill out the 70[Corporate Contributor License Agreement](http://code.google.com/legal/corporate-cla-v1.0.html) 71and send it to us as described on that page. Add your (or your organization's) 72name and contact info to the AUTHORS file as a part of your CL. 73 74Now that you've made a change and written a test for it, it's ready for the code 75review! Submit a patch and getting it reviewed is fairly easy with depot tools. 76 77Use `git-cl`, which comes with 78[depot tools](http://sites.google.com/a/chromium.org/dev/developers/how-tos/install-depot-tools). 79For help, run `git cl help`. Note that in order for `git cl` to work correctly, 80it needs to run on a clone of <https://skia.googlesource.com/skia>. Using clones 81of mirrors, including Google's mirror on GitHub, might lead to issues with 82`git cl` usage. 83 84### Find a reviewer 85 86Ideally, the reviewer is someone who is familiar with the area of code you are 87touching. Look at the git blame for the file to see who else has been editing 88it. If unsuccessful, another option is to click on the 'Suggested Reviewers' 89button to add one of the listed Skia contacts. They should be able to add 90appropriate reviewers for your change. The button is located here: 91<img src="/docs/dev/contrib/SuggestedReviewers.png" style="display: inline-block; max-width: 75%" /> 92 93### Uploading changes for review 94 95Skia uses the Gerrit code review tool. Skia's instance is 96[skia-review](http://skia-review.googlesource.com). Use `git cl` to upload your 97change: 98 99<!--?prettify lang=sh?--> 100 101 git cl upload 102 103You may have to enter a Google Account username and password to authenticate 104yourself to Gerrit. A free gmail account will do fine, or any other type of 105Google account. It does not have to match the email address you configured using 106`git config --global user.email` above, but it can. 107 108The command output should include a URL, similar to 109([https://skia-review.googlesource.com/c/4559/](https://skia-review.googlesource.com/c/4559/)), 110indicating where your changelist can be reviewed. 111 112### Submit try jobs 113 114Skia's trybots allow testing and verification of changes before they land in the 115repo. You need to have permission to trigger try jobs; if you need permission, 116ask a committer. After uploading your CL to 117[Gerrit](https://skia-review.googlesource.com/), you may trigger a try job for 118any job listed in tasks.json, either via the Gerrit UI, using `git cl try`, eg. 119 120 git cl try -B skia.primary -b Some-Tryjob-Name 121 122or using bin/try, a small wrapper for `git cl try` which helps to choose try 123jobs. From a Skia checkout: 124 125 bin/try --list 126 127You can also search using regular expressions: 128 129 bin/try "Test.*GTX660.*Release" 130 131For more information about testing, see 132[testing infrastructure](/docs/dev/testing/automated_testing). 133 134### Request review 135 136Go to the supplied URL or go to the code review page and select the **Your** 137dropdown and click on **Changes**. Select the change you want to submit for 138review and click **Reply**. Enter at least one reviewer's email address. Now add 139any optional notes, and send your change off for review by clicking on **Send**. 140Unless you send your change to reviewers, no one will know to look at it. 141 142_Note_: If you don't see editing commands on the review page, click **Sign in** 143in the upper right. _Hint_: You can add -r [email protected] --send-mail to 144send the email directly when uploading a change using `git-cl`. 145 146## The review process 147 148If you submit a giant patch, or do a bunch of work without discussing it with 149the relevant people, you may have a hard time convincing anyone to review it! 150 151Code reviews are an important part of the engineering process. The reviewer will 152almost always have suggestions or style fixes for you, and it's important not to 153take such suggestions personally or as a commentary on your abilities or ideas. 154This is a process where we work together to make sure that the highest quality 155code gets submitted! 156 157You will likely get email back from the reviewer with comments. Fix these and 158update the patch set in the issue by uploading again. The upload will explain 159that it is updating the current CL and ask you for a message explaining the 160change. Be sure to respond to all comments before you request review of an 161update. 162 163If you need to update code the code on an already uploaded CL, simply edit the 164code, commit it again locally, and then run git cl upload again e.g. 165 166 echo "GOATS" > whitespace.txt 167 git add whitespace.txt 168 git commit -m 'add GOATS fix to whitespace.txt' 169 git cl upload 170 171Once you're ready for another review, use **Reply** again to send another 172notification (it is helpful to tell the reviewer what you did with respect to 173each of their comments). When the reviewer is happy with your patch, they will 174approve your change by setting the Code-Review label to "+1". 175 176_Note_: As you work through the review process, both you and your reviewers 177should converse using the code review interface, and send notes. 178 179Once your change has received an approval, you can click the "Submit to CQ" 180button on the codereview page and it will be committed on your behalf. 181 182Once your commit has gone in, you should delete the branch containing your 183change: 184 185 git checkout -q origin/main 186 git branch -D my_feature 187 188## Final Testing 189 190Skia's principal downstream user is Chromium, and any change to Skia rendering 191output can break Chromium. If your change alters rendering in any way, you are 192expected to test for and alleviate this. You may be able to find a Skia team 193member to help you, but the onus remains on each individual contributor to avoid 194breaking Chrome. 195 196### Evaluating Impact on Chromium 197 198Keep in mind that Skia is rolled daily into Blink and Chromium. Run local tests 199and watch canary bots for results to ensure no impact. If you are submitting 200changes that will impact layout tests, follow the guides below and/or work with 201your friendly Skia-Blink engineer to evaluate, rebaseline, and land your 202changes. 203 204Resources: 205 206[How to land Skia changes that change Blink layout test results](/docs/dev/chrome/blink/) 207 208If you're changing the Skia API, you may need to make an associated change in 209Chromium. If you do, please follow these instructions: 210[Landing Skia changes which require Chrome changes](/docs/dev/chrome/changes/) 211 212## Check in your changes 213 214### Non-Skia-committers 215 216If you already have committer rights, you can follow the directions below to 217commit your change directly to Skia's repository. 218 219If you don't have committer rights in https://skia.googlesource.com/skia.git ... 220first of all, thanks for submitting your patch! We really appreciate these 221submissions. After receiving an approval from a committer, you will be able to 222click the "Submit to CQ" button and submit your patch via the commit queue. 223 224In special instances, a Skia committer may assist you in landing the change by 225uploading a new codereview containing your patch (perhaps with some small 226adjustments at their discretion). If so, you can mark your change as 227"Abandoned", and update it with a link to the new codereview. 228 229### Skia committers 230 231- tips on how to apply an externally provided patch are [here](../patch) 232- when landing externally contributed patches, please note the original 233 contributor's identity (and provide a link to the original codereview) in the 234 commit message 235 236 `git-cl` will squash all your commits into a single one with the description 237 you used when you uploaded your change. 238 239 ``` 240 git cl land 241 ``` 242 243 or 244 245 ``` 246 git cl land -c 'Contributor Name <[email protected]>' 247 ``` 248