~ubuntu-branches/ubuntu/saucy/golang/saucy

« back to all changes in this revision

Viewing changes to doc/contribute.html

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-07-08 05:52:37 UTC
  • mfrom: (29.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20130708055237-at01839e0hp8z3ni
Tags: 2:1.1-1ubuntu1
016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
<p>
8
8
This document explains how to contribute changes to the Go project.
9
9
It assumes you have installed Go using the
10
 
<a href="/doc/install">installation instructions</a> and
 
10
<a href="/doc/install/source">installation instructions</a> and
11
11
have <a href="code.html">written and tested your code</a>.
12
12
(Note that the <code>gccgo</code> frontend lives elsewhere;
13
13
see <a href="gccgo_contribute.html">Contributing to gccgo</a>.)
46
46
 
47
47
<pre>
48
48
cd $GOROOT/src
49
 
./all.bash
50
 
</pre>
51
 
 
52
 
<p>
53
 
The final line printed by <code>make all</code> should be of the form:
54
 
</p>
55
 
 
56
 
<pre>
57
 
<i>N</i> known bugs; 0 unexpected bugs
58
 
</pre>
59
 
 
60
 
<p>
61
 
The value of <i>N</i> varies over time, but the line must
62
 
say &ldquo;<code>0 unexpected bugs</code>&rdquo; and must not
63
 
add &ldquo;<code>test output differs</code>.&rdquo;
64
 
</p>
65
 
 
 
49
./all.bash    # On Windows, run all.bat
 
50
</pre>
 
51
 
 
52
<p>
 
53
After running for a while, the command should print "<code>ALL TESTS PASSED</code>".
 
54
</p>
66
55
 
67
56
<h2 id="Code_review">Code review</h2>
68
57
 
104
93
command.
105
94
</p>
106
95
 
107
 
<p>
108
 
Mercurial power users: if you prefer to use the Mercurial Queues extension, see
109
 
<a href="codereview_with_mq.html">Using Mercurial Queues with Codereview</a>.
110
 
</p>
111
 
 
112
96
<h3>Configure the extension</h3>
113
97
 
114
98
<p>Edit <code>$GOROOT/.hg/hgrc</code> to add:</p>
115
99
 
116
100
<pre>
117
101
[extensions]
118
 
codereview = YOUR_GO_ROOT/lib/codereview/codereview.py
 
102
codereview = $GOROOT/lib/codereview/codereview.py
119
103
 
120
104
[ui]
121
105
username = Your Name &lt;you@server.dom&gt;
122
106
</pre>
123
107
 
124
 
<p>Replace YOUR_GO_ROOT with the value of <code>$GOROOT</code>.
125
 
The Mercurial configuration file format does not allow environment variable substitution.
 
108
<p>
126
109
The <code>username</code> information will not be used unless
127
110
you are a committer (see below), but Mercurial complains if it is missing.
128
111
</p>
129
112
 
 
113
<p>
 
114
After adding the extension, <code>hg help codereview</code>
 
115
will show documentation for its commands. As the codereview extension is only
 
116
enabled for your checkout in <code>$GOROOT</code>, the remainder of this
 
117
document assumes you are inside <code>$GOROOT</code> when issuing commands.
 
118
</p>
 
119
 
 
120
<p>
 
121
Windows users may need to perform extra steps to get the code review 
 
122
extension working. See the
 
123
<a href="https://code.google.com/p/go-wiki/wiki/CodeReview">CodeReview page</a> 
 
124
on the <a href="http://code.google.com/p/go-wiki/wiki">Go Wiki</a> for details.
 
125
</p>
 
126
 
130
127
<h3>Log in to the code review site.</h3>
131
128
 
132
129
<p>
133
130
The code review server uses a Google Account to authenticate.
134
131
(If you can use the account to
135
132
<a href="https://www.google.com/accounts/Login?hl=en&amp;continue=http://www.google.com/">sign in at google.com</a>,
136
 
you can use it to sign in to the code review server.
 
133
you can use it to sign in to the code review server.)
137
134
The email address you use on the Code Review site
138
135
will be recorded in the <a href="http://code.google.com/p/go/source/list">Mercurial change log</a>
139
136
and in the <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file.
140
137
You can <a href="https://www.google.com/accounts/NewAccount">create a Google Account</a>
141
138
associated with any address where you receive email.
 
139
If you've enabled the two-step verification feature, don't forget to generate an
 
140
application-specific password and use that when prompted for a password.
142
141
</p>
143
142
 
144
143
<pre>
163
162
For example, <code>rsc</code> is an alias for <code>rsc@golang.org</code>.
164
163
</p>
165
164
 
 
165
<h3>Switch to the default branch</h3>
 
166
 
 
167
<p>
 
168
Most Go installations use a release branch, but new changes should
 
169
only be made to the default branch. (They may be applied later to a release
 
170
branch as part of the release process.)
 
171
Before making a change, make sure you use the default branch:
 
172
</p>
 
173
 
 
174
<pre>
 
175
$ hg update default
 
176
</pre>
 
177
 
166
178
<h3>Make a change</h3>
167
179
 
168
180
<p>
263
275
the change with issue 159 in the <a href="http://code.google.com/p/go/issues/list">Go issue tracker</a>.
264
276
When this change is eventually submitted, the issue
265
277
tracker will automatically mark the issue as fixed.
 
278
(These conventions are described in detail by the
 
279
<a href="http://code.google.com/p/support/wiki/IssueTracker#Integration_with_version_control">Google Project Hosting Issue Tracker documentation</a>.)
266
280
</p>
267
281
 
268
282
<p>
277
291
CL created: http://codereview.appspot.com/99999
278
292
</pre>
279
293
 
 
294
<h3>Adding or removing files from an existing change</h3>
 
295
 
280
296
<p>
281
 
If you need to re-edit the change description,
 
297
If you need to re-edit the change description, or change the files included in the CL,
282
298
run <code>hg change 99999</code>.
283
299
</p>
284
300
 
285
301
<p>
286
 
You can see a list of your pending changes by running <code>hg pending</code> (<code>hg p</code> for short).
287
 
</p>
288
 
 
 
302
Alternatively, you can use
 
303
</p>
 
304
 
 
305
<pre>
 
306
$ hg file 99999 somefile
 
307
</pre>
 
308
 
 
309
<p>
 
310
to add <code>somefile</code> to CL 99999, and
 
311
</p>
 
312
 
 
313
<pre>
 
314
$ hg file -d 99999 somefile
 
315
</pre>
 
316
 
 
317
<p>
 
318
to remove <code>somefile</code> from the CL.
 
319
</p>
 
320
 
 
321
<p>
 
322
A file may only belong to a single active CL at a time. <code>hg file</code>
 
323
will issue a warning if a file is moved between changes.
 
324
</p>
289
325
 
290
326
<h3>Synchronize your client</h3>
291
327
 
378
414
 
379
415
<h3>Mail the change for review</h3>
380
416
 
 
417
<p>
 
418
Creating or uploading the change uploads a copy of the diff to the code review server,
 
419
but it does not notify anyone about it. To do that, you need to run <code>hg mail</code>
 
420
(see below).
 
421
</p>
 
422
 
381
423
<p>To send out a change for review, run <code>hg mail</code> using the change list number
382
424
assigned during <code>hg change</code>:</p>
383
425
 
399
441
 
400
442
<p>Note that <code>-r</code> and <code>--cc</code> cannot be spelled <code>--r</code> or <code>-cc</code>.</p>
401
443
 
 
444
<p>
 
445
If your change relates to an open issue, please add a comment to the issue
 
446
announcing your proposed fix, including a link to your CL.
 
447
</p>
402
448
 
403
449
<h3>Reviewing code</h3>
404
450
 
412
458
 
413
459
<h3>Revise and upload</h3>
414
460
 
415
 
<p>You will probably revise your code in response to the reviewer comments.
 
461
<p>
 
462
You will probably revise your code in response to the reviewer comments. When
 
463
you have done this, you can upload your change to the code review server
 
464
without sending a notification by running <code>hg upload</code> using the change
 
465
list number assigned during <code>hg change</code>
 
466
</p>
 
467
 
 
468
<pre>
 
469
$ hg upload 99999
 
470
</pre>
 
471
 
 
472
<p>
416
473
When you have revised the code and are ready for another round of review, run
417
474
</p>
418
475
 
433
490
<code>LGTM</code>: looks good to me.
434
491
</p>
435
492
 
 
493
<p>
 
494
You can see a list of your pending changes by running <code>hg pending</code> (<code>hg p</code> for short).
 
495
</p>
 
496
 
 
497
<h3>Reviewing code by others</h3>
 
498
 
 
499
<p>
 
500
You can import a CL proposed by someone else into your local Mercurial client
 
501
by using the <code>hg clpatch</code> command. Running
 
502
</p>
 
503
 
 
504
<pre>
 
505
$ hg clpatch 99999
 
506
</pre>
 
507
 
 
508
<p>
 
509
will apply the latest diff for CL 99999 to your working copy. If any of the
 
510
files referenced in CL 99999 have local modifications, <code>clpatch</code>
 
511
will refuse to apply the whole diff. Once applied, CL 99999 will show up in
 
512
the output of <code>hg pending</code> and others.
 
513
</p>
 
514
 
 
515
<p>
 
516
To revert a CL you have applied locally, use the <code>hg revert</code>
 
517
command. Running
 
518
</p>
 
519
 
 
520
<pre>
 
521
$ hg revert @99999
 
522
</pre>
 
523
 
 
524
<p>
 
525
will revert any files mentioned on CL 99999 to their original state. This can
 
526
be an effective way of reverting one CL revision and applying another.
 
527
</p>
 
528
 
 
529
<p>
 
530
Once the CL has been submitted, the next time you run <code>hg sync</code>
 
531
it will be removed from your local pending list. Occasionally the pending list
 
532
can get out of sync leaving stale references to closed or abandoned CLs.
 
533
You can use <code>hg change -D 99999</code> to remove the reference to CL 99999.
 
534
</p>
 
535
 
436
536
<h3>Submit the change after the review</h3>
437
537
 
438
538
<p>
439
539
After the code has been <code>LGTM</code>'ed, it is time to submit
440
540
it to the Mercurial repository.
 
541
</p>
 
542
 
 
543
<p>
 
544
If you are not a committer, you cannot submit the change directly.
 
545
Instead a committer, usually the reviewer who said <code>LGTM</code>,
 
546
will run:
 
547
</p>
 
548
 
 
549
<pre>
 
550
$ hg clpatch 99999
 
551
$ hg submit 99999
 
552
</pre>
 
553
 
 
554
<p>
 
555
The <code>submit</code> command submits the code.  You will be listed as the
 
556
author, but the change message will also indicate who the committer was.
 
557
Your local client will notice that the change has been submitted
 
558
when you next run <code>hg sync</code>.
 
559
</p>
 
560
 
 
561
<p>
441
562
If you are a committer, you can run:
442
563
</p>
443
564
 
454
575
 
455
576
<p>
456
577
If your local copy of the repository is out of date,
457
 
<code>hg submit</code>
458
 
will refuse the change:
 
578
<code>hg submit</code> will refuse the change:
459
579
</p>
460
580
 
461
581
<pre>
463
583
local repository out of date; must sync before submit
464
584
</pre>
465
585
 
466
 
<p>
467
 
If you are not a committer, you cannot submit the change directly.
468
 
Instead, a committer, usually the reviewer who said <code>LGTM</code>,
469
 
will run:
470
 
</p>
471
 
 
472
 
<pre>
473
 
$ hg clpatch 99999
474
 
$ hg submit 99999
475
 
</pre>
476
 
 
477
 
<p>The <code>clpatch</code> command imports your change 99999 into
478
 
the committer's local Mercurial client, at which point the committer
479
 
can check or test the code more.
480
 
(Anyone can run <code>clpatch</code> to try a change that
481
 
has been uploaded to the code review server.)
482
 
The <code>submit</code> command submits the code.  You will be listed as the
483
 
author, but the change message will also indicate who the committer was.
484
 
Your local client will notice that the change has been submitted
485
 
when you next run <code>hg sync</code>.
486
 
</p>
487
 
 
488
 
 
489
 
<h3 id="copyright">Copyright</h3>
 
586
<h2 id="copyright">Copyright</h2>
490
587
 
491
588
<p>Files in the Go repository don't list author names,
492
589
both to avoid clutter and to avoid having to keep the lists up to date.
497
594
 
498
595
<p>The <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file
499
596
defines who the Go contributors&mdash;the people&mdash;are;
500
 
the <a href="/AUTHORS"><code>AUTHORS</code></a> file, which defines
 
597
the <a href="/AUTHORS"><code>AUTHORS</code></a> file defines
501
598
who &ldquo;The Go Authors&rdquo;&mdash;the copyright holders&mdash;are.
502
599
The Go developers at Google will update these files when submitting
503
600
your first change.
525
622
<p>Code that you contribute should use the standard copyright header:</p>
526
623
 
527
624
<pre>
528
 
// Copyright 2012 The Go Authors. All rights reserved.
 
625
// Copyright 2013 The Go Authors. All rights reserved.
529
626
// Use of this source code is governed by a BSD-style
530
627
// license that can be found in the LICENSE file.
531
628
</pre>
 
629
 
 
630
<p>
 
631
Files in the repository are copyright the year they are added. It is not
 
632
necessary to update the copyright year on files that you change.
 
633
</p>