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