blob: 1fb9db147accce05b828893bface7cfbe93510ae [file] [log] [blame] [view]
Skyler Kaufman44436912011-04-07 15:11:52 -07001<!--
2 Copyright 2010 The Android Open Source Project
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15-->
16
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070017# Submitting Patches #
18
Jean-Baptiste Queruc173c702012-04-12 15:26:24 -070019This page describes the full process of submitting a patch to the AOSP, including
20reviewing and tracking changes with [Gerrit](https://android-review.googlesource.com/).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070021
22## Prerequisites ##
23
24- Before you follow the instructions on this page, you will need to set up your
25local working environment and get the Android source files. For instructions,
26follow the "Getting Started" section [here](downloading.html).
27
28- For details about Repo and Git, see [Version Control](version-control.html).
29
30- For information about the different roles you can play within the Android
Dan Morrill669d3642011-04-07 14:37:55 -070031Open Source community, see [Project roles](/source/roles.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070032
33- If you plan to contribute code to the Android platform, be sure to read
Dan Morrill669d3642011-04-07 14:37:55 -070034the [AOSP's licensing information](/source/licenses.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070035
36- Note that changes to some of the upstream projects used by Android should be
37made directly to that project, as described in [Upstream Projects](#upstream-projects).
38
Skyler Kaufman44436912011-04-07 15:11:52 -070039# For contributors #
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070040
Skyler Kaufman44436912011-04-07 15:11:52 -070041## Start a repo branch ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070042
Skyler Kaufman44436912011-04-07 15:11:52 -070043For each change you intend to make, start a new branch within the relevant git repository:
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070044
Yegor Yefremov01902492012-02-21 22:18:44 +010045 $ repo start NAME .
Skyler Kaufman44436912011-04-07 15:11:52 -070046
47You can start several independent branches at the same time in the same repository. The branch NAME is local to your workspace and will not be included on gerrit or the final source tree.
48
49## Make your change ##
50
51Once you have modified the source files (and validated them, please) commit the changes to your local repository:
52
53 $ git add -A
54 $ git commit -s
55
56Provide a detailed description of the change in your commit message. This description will be pushed to the public AOSP repository, so please follow our guidelines for writing changelist descriptions:
57
58- Start with a one-line summary (60 characters max), followed by a blank line. This format is used by git and gerrit for various displays.
59
60 short description on first line
61
62 more detailed description of your patch,
63 which is likely to take up multiple lines.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070064
65- The description should focus on what issue it solves, and how it solves it. The second part is somewhat optional when implementing new features, though desirable.
66
Skyler Kaufman44436912011-04-07 15:11:52 -070067- Include a brief note of any assumptions or background information that may be important when another contributor works on this feature next year.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070068
Skyler Kaufman44436912011-04-07 15:11:52 -070069A unique change ID and your name and email as provided during `repo init` will be automatically added to your commit message.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070070
Skyler Kaufman44436912011-04-07 15:11:52 -070071## Upload to gerrit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070072
Skyler Kaufman44436912011-04-07 15:11:52 -070073Once you have committed your change to your personal history, upload it to gerrit with
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070074
Skyler Kaufman44436912011-04-07 15:11:52 -070075 $ repo upload
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070076
Skyler Kaufman44436912011-04-07 15:11:52 -070077If you have started multiple branches in the same repository, you will be prompted to select which one(s) to upload.
Skyler Kaufman991ae4d2011-04-07 12:30:41 -070078
Jean-Baptiste Queru0e3ee322012-01-11 05:42:17 -080079After a successful upload, repo will provide you the URL of a new page on
80[Gerrit](https://android-review.googlesource.com/). Visit this link to view
81your patch on the review server, add comments, or request specific reviewers
82for your patch.
Skyler Kaufman44436912011-04-07 15:11:52 -070083
84## Uploading a replacement patch ##
85
86Suppose a reviewer has looked at your patch and requested a small modification. You can amend your commit within git, which will result in a new patch on gerrit with the same change ID as the original.
87
88*Note that if you have made other commits since uploading this patch, you will need to manually move your git HEAD.*
89
90 $ git add -A
91 $ git commit --amend
92
93When you upload the amended patch, it will replace the original on gerrit and in your local git history.
94
95## Resolving sync conflicts ##
96
97If other patches are submitted to the source tree that conflict with yours, you will need to rebase your patch on top of the new HEAD of the source repository. The easy way to do this is to run
98
99 $ repo sync
100
101This command first fetches the updates from the source server, then attempts to automatically rebase your HEAD onto the new remote HEAD.
102
103If the automatic rebase is unsuccessful, you will have to perform a manual rebase.
104
105 $ git rebase master
106
107Using `git mergetool` may help you deal with the rebase conflict. Once you have successfully merged the conflicting files,
108
109 $ git rebase --continue
110
111After either automatic or manual rebase is complete, run `repo upload` to submit your rebased patch.
112
113## After a submission is approved ##
114
Conley Owens75539812012-02-21 11:53:05 -0800115After a submission makes it through the review and verification process, Gerrit automatically merges the change into the public repository. Other users will be able to run `repo sync` to pull the update into their local client.
Skyler Kaufman44436912011-04-07 15:11:52 -0700116
117# For reviewers and verifiers #
118
119## Reviewing a change ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700120
121If you are assigned to be the Approver for a change, you need to determine the following:
122
123- Does this change fit within this project's stated purpose?
124
125- Is this change valid within the project's existing architecture?
126
127- Does this change introduce design flaws that will cause problems in the future?
128
129- Does this change follow the best practices that have been established for this project?
130
131- Is this change a good way to perform the described function?
132
133- Does this change introduce any security or instability risks?
134
135If you approve of the change, mark it with LGTM ("Looks Good to Me") within Gerrit.
136
Skyler Kaufman44436912011-04-07 15:11:52 -0700137## Verifying a change ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700138
139If you are assigned to be the Verifier for a change, you need to do the following:
140
141- Patch the change into your local client using one of the Download commands.
142
143- Build and test the change.
144
145- Within Gerrit use Publish Comments to mark the commit as "Verified" or "Fails," and add a message explaining what problems were identified.
146
Skyler Kaufman44436912011-04-07 15:11:52 -0700147## Downloading changes from Gerrit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700148
149A submission that has been verified and merged will be downloaded with the next `repo sync`. If you wish to download a specific change that has not yet been approved, run
150
151 $ repo download TARGET CHANGE
152
153where TARGET is the local directory into which the change should be downloaded and CHANGE is the
Jean-Baptiste Queru0e3ee322012-01-11 05:42:17 -0800154change number as listed in [Gerrit](https://android-review.googlesource.com/). For more information,
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700155see the [Repo reference](/source/using-repo.html).
156
Skyler Kaufman44436912011-04-07 15:11:52 -0700157## How do I become a Verifier or Approver? ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700158
159In short, contribute high-quality code to one or more of the Android projects.
160For details about the different roles in the Android Open Source community and
Dan Morrill669d3642011-04-07 14:37:55 -0700161who plays them, see [Project Roles](/source/roles.html).
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700162
Skyler Kaufman44436912011-04-07 15:11:52 -0700163## Diffs and comments ##
164
165To open the details of the change within Gerrit, click on the "Id number" or "Subject" of a change. To compare the established code with the updated code, click the file name under "Side-by-side diffs."
166
167## Adding comments ##
168
169Anyone in the community can use Gerrit to add inline comments to code submissions. A good comment will be relevant to the line or section of code to which it is attached in Gerrit. It might be a short and constructive suggestion about how a line of code could be improved, or it might be an explanation from the author about why the code makes sense the way it is.
170
171To add an inline comment, double-click the relevant line of the code and write your comment in the text box that opens. When you click Save, only you can see your comment.
172
173To publish your comments so that others using Gerrit will be able to see them, click the Publish Comments button. Your comments will be emailed to all relevant parties for this change, including the change owner, the patch set uploader (if different from the owner), and all current reviewers.
174
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700175<a name="upstream-projects"></a>
176
Skyler Kaufman44436912011-04-07 15:11:52 -0700177# Upstream Projects #
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700178
179Android makes use of a number of other open-source projects, such as the Linux kernel and WebKit, as described in
180[Branches and Releases](/source/code-lines.html). For the upstream projects detailed below, changes should be made directly upstream. Such changes will be incorporated into the Android tree as part of the usual process of pulling these projects.
181
Skyler Kaufman44436912011-04-07 15:11:52 -0700182## WebKit ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700183
184All changes to the WebKit project at `external/webkit` should be made
185upstream at [webkit.org](http://www.webkit.org). The process begins by filing a WebKit bug.
186This bug should use `Android` for the `Platform` and `OS`
187fields only if the bug is specific to Android. Bugs are far more likely to receive the reviewers'
188attention once a proposed fix is added and tests are included. See
189[Contributing Code to WebKit](http://webkit.org/coding/contributing.html) for details.
190
Skyler Kaufman44436912011-04-07 15:11:52 -0700191## V8 ##
Skyler Kaufman991ae4d2011-04-07 12:30:41 -0700192
193All changes to the V8 project at `external/v8` should be submitted upstream at
194[code.google.com/p/v8](http://code.google.com/p/v8). See [Contributing to V8](http://code.google.com/p/v8/wiki/Contributing)
195for details.
196