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