blob: 938bee76ee646fc30d2de6ce8dd342858c092171 [file] [log] [blame]
<?php
$title="Contributing Code";
$extra_head_content = <<<END
<style type="text/css">
img {
border:1px solid black
}
</style>
END;
include("../header.inc");
?>
<h2>Contributing Code</h2>
<p>This page describes how to contribute changes to the WebKit
source control repository.
The WebKit project maintains several <a href="scripts.html">scripts</a>
to assist you. This page assumes you already know how to
<a href="/building/checkout.html">check out</a> and
<a href="/building/build.html">build</a> the code.</p>
<h3>Overview</h3>
<p>Below are the recommended steps.
Later sections of this page explain each step in more detail.
</p>
<ol>
<li>Choose or create a <a href="#bugreport">bug report</a> to work on.</li>
<li><a href="#writecode">Develop</a> your changes.</li>
<li>Make sure your changes meet the <a href="/coding/coding-style.html">code
style guidelines</a>. The <code>check-webkit-style</code> script may be of
help.</li>
<li>Run the layout tests using the <code>run-webkit-tests</code> script and make sure they all pass.
See the <a href="/quality/testwriting.html">testing page</a> for more information, as well as what you need to do if you've modified JavaScriptCore.</li>
<li>Add any <a href="#newfiles">new files</a> to your working directory.</li>
<li>Prepare a change log entry. You may have to add entries to multiple ChangeLogs. The <code>prepare-ChangeLog</code> script will create stub entries for you. See the <a href="#changelogs">paragraph about ChangeLogs</a> below.</li>
<li>Create the patch using the <code>svn-create-patch</code> script.</li>
<li><a href="#submit">Submit</a> your patch for review to
<a href="https://bugs.webkit.org/">bugs.webkit.org</a>.</li>
<li>Make any changes recommended by the reviewer.</li>
<li>Once reviewed, ask someone to land your patch or mark it for <a href="#commitqueue">automated commit</a>.
<li>Please watch for any regressions it may have caused (hopefully none)!</li>
</ol>
<p>More detail about these steps is below.</p>
<h3 id="bugreport">Choose a bug report</h3>
<p>The <a href="https://bugs.webkit.org/">bugs.webkit.org</a> database
is the central point of communication for contributions to WebKit.
Nearly every contribution corresponds to a bug report there.
Note that WebKit uses bug reports to track all types of code changes
and not just bug fixes.
</p>
<p>Choose a bug report to work on. You can also create a new report.
Be sure to search the database before creating new reports to avoid
duplication.</p>
<p>After choosing a bug report, follow the
WebKit <a href="/quality/lifecycle.html">bug life cycle</a> guidelines
for the report. For example, it is often good practice to comment
in a report if you are working on that issue. If your change
may be controversial, you may want to check in advance with the
<a href="http://lists.webkit.org/mailman/listinfo/webkit-dev">
webkit-dev</a> mailing list.</p>
<h3 id="writecode">Develop your changes</h3>
<p>If you make substantive changes to a file, you may wish to add a
copyright line for yourself or for the company on whose behalf you
work. Below are sample copyright lines for an individual contributor
and a company:
<p><code>Copyright (C) 2010 John Smith (jsmith@example.com)</code></p>
<p><code>Copyright (C) 2010 Company Inc. All rights reserved.</code></p>
<p>In addition, make sure that any new source code and script files
you introduce contain license text at the beginning of the file.
If you are the author of a new file, preferred license text to include
can be found here:
<a href="http://trac.webkit.org/browser/trunk/WebKit/LICENSE">WebKit/LICENSE</a>.
(The "Original Format" link at the bottom of the page contains text
that can be cut and pasted more easily.) Simply replace the copyright
line with your own information, for example as suggested above.
<h3>Code Style Guidelines</h3>
<p>Patches must comply with the <a href="/coding/coding-style.html">code style guidelines</a>.
Some older parts of the codebase do not follow these guidelines.
If you are modifying such code, it is generally best to clean it up
to comply with the current guidelines. An exception is legacy components,
which should not be cleaned up.</p>
<h3>Regression tests</h3>
<p>Once you have made your changes, you need to run the regression tests, which is done via the <code>run-webkit-tests</code> script.
All tests must pass. Patches will not be landed in the tree if they break existing layout tests.</p>
<p>For any feature that affects the layout engine, a new regression test must be constructed. If you provide a patch that fixes a bug,
that patch should also include the addition of a regression test that would fail without the patch and succeed with the patch.
If no regression test is provided, the reviewer will ask you to revise the patch, so you can save time by constructing the test up
front and making sure it's attached to the bug. If no layout test can be (or needs to be) constructed for the fix, you must explain
why a new test isn't necessary to the reviewer.</p>
<p>Information on writing a layout test as well as what needs to be done if you've made changes to JavaScriptCore
can be found on the <a href="/quality/testwriting.html">testing page</a>.</p>
<h3 id="newfiles">Add new files to your working directory</h3>
<p>If your changes include adding new files (like new layout tests),
use the <code>svn add</code> command to mark these files for addition to the
repository. If you do not do this, the new files will be missing from
the patch file you generate below.</p>
<p>You can learn more about Subversion commands like <code>svn add</code>
from the online book <a class="book" href="http://svnbook.red-bean.com/">
Version Control with Subversion</a> and by using the <code>svn help</code>
command.</p>
<h3 id="changelogs">ChangeLog files</h3>
<p>ChangeLogs are simple text files which provide historical documentation for all changes to the WebKit project. All patches require an entry to the ChangeLog. The <code>prepare-ChangeLog</code> script will create a basic entry containing a list of all files that have been changed. The first line contains the date, your full name, and your email address. Use this to write up a brief summary of the changes you've made. Don't worry about the "Reviewed by NOBODY (OOPS!)" line, the person landing your patch will fill this in.</p>
<p>There is one ChangeLog per top-level directory, if you changed code and tests you will need to edit at least two ChangeLogs. The <code>prepare-ChangeLog</code> script will create a stub entries for you. You should edit these stubs to describe your change, including the full url to the bug (<a href="http://trac.webkit.org/changeset/43259">example entry</a>, note that you can use <code>--bug</code> flag). (You should set EMAIL_ADDRESS and CHANGE_LOG_NAME in your environment if you will be running this script frequently.)</p>
<p>The "No new tests. (OOPS!)" line appears if <code>prepare-ChangeLog</code> did not detect the addition of test cases. If your patch does not require test cases (or test cases are not possible), you should include a line stating such. Otherwise all changes require test cases which should be mentioned in the ChangeLog.</p>
<h3>Create the patch</h3>
<p>WebKit uses <code>svn-create-patch</code> to create patches. The
<code>svn-create-patch</code> script is a small wrapper around Subversion's
<code>diff</code> command that better handles moved, added, and deleted files.
This command is best run from the top level of your checkout
to make sure no changes are left out of your patch. It is not necessary to
break a patch into multiple files.</p>
<p>The <code>svn-create-patch</code> script does not create a file automatically.
You need to redirect the output yourself using something like:</p>
<p class="code">svn-create-patch > MyExcellentPatch.txt</p>
<h3 id="submit">Submit your patch</h3>
<p>Submit your patch by clicking the "Add an attachment" link in the
<a href="#bugreport">bug report</a> you chose for your contribution.</p>
<p><img src="images/contribute_add_attachment.png"
alt='Bugzilla "Add an attachment" link'></p>
<p>Complete the attachment form by doing at least the following:
<ol>
<li>Browse to your patch file in the File field.</li>
<li>Type a brief description in the Description field, for example
"Proposed patch."</li>
<li>Check the "patch" checkbox (see picture below).</li>
<li>Select the question mark "?" in the "review" pull-down
(see picture below).</li>
<li>Click Submit at the bottom.</li>
</ol>
</p>
<p><img src="images/contribute_mark_review.png"
alt="Bugzilla patch-submission options"></p>
<p>The patch checkbox and the <code>review:?</code> flag signal to
WebKit reviewers that your patch is ready for review.
Setting the review flag also sends an automatic e-mail to the
<a href="http://lists.webkit.org/mailman/listinfo/webkit-reviews">
webkit-reviews</a> mailing list which some reviewers subscribe to.
</p>
<h3>Respond to reviewers</h3>
<p>A WebKit reviewer must approve your patch before WebKit can accept
it into the source control repository.
A reviewer will typically either approve your patch
(by responding with an <code>r=me</code> in the bug report and marking the patch <code>review:+</code>) or request revisions
to your patch (and mark the patch <code>review:-</code>). In rare cases a patch may be permanently rejected, meaning that the reviewer
believes the feature should never be committed to the tree. The review process can consist of multiple iterations between you and
the reviewer as you submit revised patches.</p>
<h3 id="landing">Landing in the tree</h3>
<p>Once a patch is approved, you should ask <a href="https://lists.webkit.org/mailman/roster.cgi/webkit-committers">someone with commit access</a> to land your patch. Alternatively you can request that your patch be committed by our <a href="#commitqueue">commit bot</a>.</p>
<h4>Keeping the tree green</h4>
<p>In either case, your responsibility for the patch does not end with the patch landing in the tree. There may be regressions from your change or additional feedback from reviewers after the patch has landed. You can watch the tree at <a href="http://build.webkit.org">build.webkit.org</a> to make sure your patch builds and passes tests on all platforms. It is your responsibility to be available should regressions arise and to respond to additional feedback that happens after a check-in.</p>
<p>Changes should succeed on all platforms, but it can be difficult to test on every platform WebKit supports. Be certain that your change does not introduce new test failures on the high-traffic Mac or Windows ports by comparing the list of failing tests before and after your change. Your change must at least compile on all platforms.</p>
<h4 id="commitqueue">Optional: Use of the WebKit Commit Bot</h4>
<p>WebKit provides an automated system (commit-queue) for landing patches for any who would like to use it. To use the commit-queue, set the <code>commit-queue:?</code> flag on your patch. A committer will set <code>commit-queue:+</code> and an automated process will download, build, run the layout tests, and submit your patch on your behalf. If the <a href="http://build.webkit.org/">WebKit buildbots</a> are passing, your patch should be landed within 15 minutes after <code>commit-queue:+</code> is set. See the <a href="https://trac.webkit.org/wiki/CommitQueue">commit-queue documentation</a> for more information.</p>
<h2>Obtaining Commit and Review Privileges</h2>
<p>Our <a href="commit-review-policy.html">Committer and Reviewer policy</a> provides details on obtaining commit and review privileges.</p>
<?php
include("../footer.inc");
?>