diff --git a/doc/contribute.html b/doc/contribute.html index d592cfc54ad..e0d1c327310 100644 --- a/doc/contribute.html +++ b/doc/contribute.html @@ -3,10 +3,14 @@ }-->
-The Go project welcomes all contributors. The process of contributing -to the Go project may be different than many projects you are used to. -This document is intended as a guide to help you through the contribution -process. This guide assumes you have a basic understanding of Git and Go. +The Go project welcomes all contributors. +
+ ++The process of contributing +to the Go project is different from that of many other projects. +This document is a guide to help you through that process. +It assumes you have a basic understanding of Git and Go.
@@ -26,13 +30,12 @@ see Contributing to gccgo.
The first step is registering as a Go contributor and configuring your environment. -Here is a very quick checklist of the required steps, that you will need -to follow: +Here is a checklist of the required steps to follow:
git
is configured to create commits with that account's e-mail address.
git
repository.
-Go to go.googlesource.com, click
+Step 2: Configure authentication credentials for the Go Git repository.
+Visit go.googlesource.com, click
on "Generate Password" (top right), and follow the instructions.
git-codereview
by running
@@ -56,8 +60,8 @@ need to be done only once for your account.
-If you prefer, we have an automated tool that walks through these steps. Just -run: +If you prefer, there is an automated tool that walks through these steps. +Just run:
@@ -67,7 +71,7 @@ $ go-contrib-init
-The rest of this chapter elaborates on these steps. +The rest of this chapter elaborates on these instructions. If you have completed the steps above (either manually or through the tool), jump to Making a change.
@@ -75,17 +79,22 @@ If you have completed the steps above (either manually or through the tool), jum-A contribution to Go is made through a Google account, with a specific -e-mail address. Make sure to pick one and use it throughout the process and -for all your contributions. You may need to decide whether to -use a personal address or a corporate address. The choice will depend on who +A contribution to Go is made through a Google account with a specific +e-mail address. +Make sure to use the same account throughout the process and +for all your subsequent contributions. +You may need to decide whether to use a personal address or a corporate address. +The choice will depend on who will own the copyright for the code that you will be writing -and submitting. Consider discussing this with your employer. +and submitting. +You might want to discuss this topic with your employer before deciding which +account to use.
-Google Accounts can either be Gmail email accounts, G-Suite organization accounts, or -accounts associated with an external e-mail address. For instance, if you need to use +Google accounts can either be Gmail email accounts, G-Suite organization accounts, or +accounts associated with an external e-mail address. +For instance, if you need to use an existing corporate e-mail that is not managed through G-Suite, you can create an account associated with your existing @@ -93,18 +102,21 @@ email address.
-You also need to make sure that git
is configured to author commits
-using the same e-mail address. You can either configure it globally
+You also need to make sure that your Git tool is configured to create commits
+using your chosen e-mail address.
+You can either configure Git globally
(as a default for all projects), or locally (for a single specific project).
You can check the current configuration with this command:
-
+
$ git config --global user.email # check current global config $ git config user.email # check current local config-
To change the configured address:
++To change the configured address: +
$ git config --global user.email name@example.com # change global config @@ -118,6 +130,7 @@ $ git config user.email name@example.com # change local config Before sending your first change to the Go project you must have completed one of the following two CLAs. Which CLA you should sign depends on who owns the copyright to your work. +
-You can check your currently signed agreements and sign new ones, through -the Google Developers +You can check your currently signed agreements and sign new ones at +the Google Developers Contributor License Agreements website. If the copyright holder for your contribution has already completed the agreement in connection with another Google open source project, @@ -143,14 +156,16 @@ it does not need to be completed again.
-If the copyright holder for the code you are submitting changes — for example,
-if you start contributing code on behalf of a new company — please send email
-to golang-dev and let us know, so that we can make sure an appropriate agreement is
+If the copyright holder for the code you are submitting changes—for example,
+if you start contributing code on behalf of a new company—please send mail
+to the golang-dev
+mailing list.
+This will let us know the situation so we can make sure an appropriate agreement is
completed and update the AUTHORS
file.
Go development happens on go.googlesource.com,
@@ -176,7 +191,8 @@ This key is paired with one generated server side, analogous to how SSH keys wor
Copy and run this script locally in your command line terminal, to store your
secret authentication token in a .gitcookies
file.
(On a Windows computer using cmd
you should instead follow the instructions
-in the yellow box to run the command. If you are using git-bash
use the same
+in the yellow box to run the command.
+If you are using git-bash
use the same
script as *nix.).
@@ -211,7 +227,8 @@ $ go get -u golang.org/x/review/git-codereview
Make sure git-codereview
is installed in your shell path, so that the
-git
command can find it. Check that
+git
command can find it.
+Check that
@@ -245,32 +262,38 @@ please file an issueCheck the issue tracker
-Whether you already know what contribution to make, or you are searching for +
+Whether you already know what contribution to make, or you are searching for an idea, the issue tracker is -always the first place to go. Issues are triaged to categorize them and manage +always the first place to go. +Issues are triaged to categorize them and manage the workflow.
-Most issues will be marked with one of the following workflow labels: +
+Most issues will be marked with one of the following workflow labels: +
+
Excluding very trivial changes, all contributions should be connected -to an existing issue. Feel free to open one and discuss what your -plans are. This process gives everyone a chance to validate the design, +to an existing issue. +Feel free to open one and discuss your plans. +This process gives everyone a chance to validate the design, helps prevent duplication of effort, and ensures that the idea fits inside the goals for the language and tools. It also checks that the design is sound before code is written; @@ -281,35 +304,43 @@ the code review tool is not the place for high-level discussions. When planning work, please note that the Go project follows a six-month development cycle. The latter half of each cycle is a three-month feature freeze during -which only bug fixes and doc updates are accepted. New contributions can be +which only bug fixes and doc updates are accepted. +New contributions can be sent during a feature freeze but will not be accepted until the freeze thaws.
-Significant changes must go through the +
+Significant changes must go through the change proposal process -before they can be accepted.
+before they can be accepted. +Sensitive security-related issues should be reported to security@golang.org.
-First-time contributors that are already familiar with the GitHub flow -are encouraged to use the same process for Go contributions. Even though Go +are encouraged to use the same process for Go contributions. +Even though Go maintainers use Gerrit for code review, a bot has been created to sync GitHub pull requests to Gerrit.
-Open a pull request as you would normally do. Gopherbot will automatically -sync the code and post a link to Gerrit. When somebody comments on the +Open a pull request as you would normally do. +Gopherbot will automatically +sync the code and post a link to Gerrit. +When somebody comments on the change, it will be posted in the pull request, so you will also get a notification.
-Some things to keep in mind: +
+Some things to keep in mind: +
It is not possible to fully sync Gerrit and GitHub, at least at the moment, -so we recommend learning Gerrit. It's different but powerful and familiarity +so we recommend learning Gerrit. +It's different but powerful and familiarity with help you understand the flow.
This is an overview of the overall process: +
+This is an overview of the overall process: +
+@@ -383,20 +418,24 @@ $ [edit files...] $ git add [files...] $ git codereview change # update same commit $ git codereview mail # send to Gerrit again +
The rest of this chapter describes these steps in more detail.
++The rest of this chapter describes these steps in more detail. +
In addition to a recent Go installation, you need to have a local copy of the source
-checked out from the correct repository. You should check out the Go source repo anywhere
-you want as long as it's outside of your GOPATH
. Either clone from
-go.googlesource.com
or GitHub:
+checked out from the correct repository.
+You should check out the Go source repo anywhere
+you want as long as it's outside of your GOPATH
.
+Either clone from
+go.googlesource.com
or from GitHub:
@@ -404,10 +443,11 @@ $ git clone https://github.com/golang/go # or https://go.googlesource.com/go $ cd go-
-Each Go change must be made in a separate branch, created from the master branch. You can use
+Each Go change must be made in a separate branch, created from the master branch.
+You can use
the normal git
commands to create a branch and add changes to the
staging area:
You can edit the commit description in your favorite editor as usual.
git
codereview
change
will automatically
-add a Change-Id
line near the bottom. That line is used by
-Gerrit to match successive uploads of the same change. Do not edit or delete it.
+add a Change-Id
line near the bottom.
+That line is used by Gerrit to match successive uploads of the same change.
+Do not edit or delete it.
This is an example:
commit fef82cf89a34935a41bd0e3c1e0c2d9d6de29ee2 (HEAD -> test) -Author: Giovanni Bajo-+Author: Giovanni Bajo <rasky@develer.com> Date: Tue Feb 13 01:07:15 2018 +0100 cmd/compile: test @@ -458,7 +499,8 @@ run will amend the existing commit. -Make sure that you always keep a single commit in each branch. If you add more +Make sure that you always keep a single commit in each branch. +If you add more commits by mistake, you can use
git
rebase
to squash them together into a single one. @@ -492,10 +534,13 @@ After running for a while, the command should print: "ALL TESTS PASSED".
Notice that you can use make.bash
instead of all.bash
-to just build the compiler without running the testsuite. Once the compiler is
+
+Notice that you can use make.bash
instead of all.bash
+to just build the compiler without running the test suite.
+Once the compiler is
built, you can run it directly from <GOCLONEDIR>/bin/go
; see also
-the section on quickly test your changes.
Go maintainers will review your code on Gerrit, and you will get notifications via email. -You can see the review on Gerrit, and comment on them. You can also reply -via email +You can see the review on Gerrit, and comment on them. +You can also reply +using email if you prefer.
@@ -557,7 +603,8 @@ Remember not to touch the specialChange-Id
line.
-Make sure that you always keep a single commit in each branch. If you add more
+Make sure that you always keep a single commit in each branch.
+If you add more
commits by mistake, you can use git rebase
to
squash them together
into a single one.
@@ -565,8 +612,14 @@ into a single one.
Commit messages in Go follow a specific convention. Read this chapter -to learn more about it. This is an example of a good one: +
+Commit messages in Go follow a specific set of conventions, +which we discuss in this section. +
+ ++Here is an example of a good one: +
math: improve Sin, Cos and Tan precision for very large arguments @@ -580,19 +633,21 @@ The algorithm is described at http://wikipedia.org/wiki/McGillicutty_Algorithm Fixes #159- -
The first line of the change description is conventionally a short one-line summary of the change, prefixed by the primary affected package. +
-It should be written so to complete the sentence "This change modifies Go to _____."
++It should be written so to complete the sentence "This change modifies Go to _____." +
The rest of the description elaborates and should provide context for the +
+The rest of the description elaborates and should provide context for the change and explain what it does. Write in complete sentences with correct punctuation, just like for your comments in Go. @@ -610,7 +665,8 @@ tracker will automatically mark the issue as fixed.
If the change is a partial step towards the resolution of the issue, -uses the notation "Updates #159". This will leave a comment in the issue +uses the notation "Updates #159". +This will leave a comment in the issue linking back to the change in Gerrit, but it will not close the issue when the change is applied.
@@ -618,7 +674,8 @@ when the change is applied.If you are sending a change against a subrepository, you must use the fully-qualified syntax supported by GitHub, to make sure the change is -linked to the issue in the main repository. The correct form is "Fixes golang/go#159". +linked to the issue in the main repository. +The correct form is "Fixes golang/go#159".
@@ -635,7 +692,8 @@ reviews after a change was submitted.When a change is submitted to Gerrit, it is usually triaged in the next few days. A maintainer will give a look and submit some initial review, that for first-time -contributors usually focus on basic cosmetics and common mistakes. For instance: +contributors usually focus on basic cosmetics and common mistakes. +For instance:
R=go1.11
,
which means that it will be reviewed later when the tree opens for a new
-development window. You can add R=go1.XX
as a comment yourself
+development window.
+You can add R=go1.XX
as a comment yourself
if you know that it's not the correct timeframe for the change and help the
maintainers.
After an initial reading of your patch, maintainers will trigger trybots, -a cluster of servers that will run the full testsuite on several different -architectures. Most trybots run complete in a few minutes, and a link will -be posted in Gerrit where you can see the results.
++After an initial reading of your patch, maintainers will trigger trybots, +a cluster of servers that will run the full test suite on several different +architectures. +Most trybots run complete in a few minutes, and a link will +be posted in Gerrit where you can see the results. +
-If the trybot run fails, follow the link and check the full logs of the -platforms on which the tests failed. Try to understand what broke, and -update your patch. Maintainers will trigger a new trybot run to see -if the problem was fixed.
++If the trybot run fails, follow the link and check the full logs of the +platforms on which the tests failed. +Try to understand what broke, update your patch to fix it, and upload again. +Maintainers will trigger a new trybot run to see +if the problem was fixed. +
-Sometimes, the tree can be broken on some platforms for a few hours; if +
+Sometimes, the tree can be broken on some platforms for a few hours; if the failure in trybot logs doesn't seem related to your patch, go to the Build Dashboard and check if the same -failures appears in the recent commits, on the same platform. In this case, +failures appears in the recent commits, on the same platform. +In this case, feel free to write a comment in Gerrit to mention that the failure is -unrelated to your change, to help maintainers understanding the situation.
+unrelated to your change, to help maintainers understanding the situation. +The Go team values very thorough reviews. Consider -each line comment like a ticket: you are expected to somehow "close" it +
+The Go team values very thorough reviews. +Think of each line comment like a ticket: you are expected to somehow "close" it by acting on it, either by implementing the suggestion or convincing the -reviewer otherwise.
+reviewer otherwise. + -After you update the change, go through line comments and make sure -to reply on every one. You can click the "Done" button to reply +
+After you update the change, go through line comments and make sure +to reply on every one. +You can click the "Done" button to reply indicating that you've implemented the reviewer's suggestion; otherwise, -click on "Reply" and explain why you have not.
+click on "Reply" and explain why you have not. + -It is absolutely normal for changes to go through several round of reviews, +
+It is absolutely normal for changes to go through several round of reviews, in which the reviewer make new comments every time and then wait for an updated -change to be uploaded. This also happens for experienced contributors, so -don't feel discouraged by it.
+change to be uploaded. +This also happens for experienced contributors, so +don't feel discouraged by it. +-At some point, reviewers will express a vote on your change. This is the -voting convention: +At some point, reviewers will express a vote on your change. +Here is the voting convention: +
+After the code has been +2'ed, an approver will -apply it to the master branch using the Gerrit UI. This is -called "submission". +apply it to the master branch using the Gerrit UI. +This is called a "submission".
@@ -740,9 +820,11 @@ the commit hashes in the repository will be changed by the "Submit" operation.
-If your change has been approved for a few days without being +
+If your change has been approved for a few days without being submitted, feel free to write a comment in Gerrit requesting -submission.
+submission. +-This section contains more in-depth topics on how to contribute to Go. Read it to -get a better understanding of the contribution process. +This section contains more in-depth topics on how to contribute to Go. +Read it to get a better understanding of the contribution process.
@@ -777,7 +859,9 @@ TheAUTHORS
file defines who “The Go
Authors”—the copyright holders—are.
-New files that you contribute should use the standard copyright header:
++New files that you contribute should use the standard copyright header: +
// Copyright 2018 The Go Authors. All rights reserved. @@ -842,23 +926,29 @@ $ git codereview mailQuickly testing your changes
-Running
all.bash
for every single change to the code tree -is burdensome. Even though it is strongly suggested to run it before ++Running
+to quickly compile and locally test your change. +all.bash
for every single change to the code tree +is burdensome. +Even though it is strongly suggested to run it before sending a change, during the normal development cycle you may want -to quickly compile and locally test your change.
make.bash
instead of all.bash
-to only rebuild the Go toolchain without running the whole testsuite. Or you
-can run run.bash
to only run the whole testsuite without rebuilding
-the toolchain. You can think of all.bash
as make.bash
+to only rebuild the Go toolchain without running the whole test suite.
+Or you
+can run run.bash
to only run the whole test suite without rebuilding
+the toolchain.
+You can think of all.bash
as make.bash
followed by run.bash
.
<GOCLONEDIR>/bin/go
; you
-can run it directly to test whatever you want to test. For instance, if you
+can run it directly to test whatever you want to test.
+For instance, if you
have modified the compiler and you want to test how it affects the
-testsuite of your own project, just run go
test
+test suite of your own project, just run go
test
using it:
@@ -883,7 +973,7 @@ $ <GOCLONEDIR>/bin/go test .
compile
tool (which is the internal binary invoked
by go
build
to compile each single package).
After that, you will want to test it by compiling or running something.
@@ -898,16 +988,17 @@ $ <GOCLONEDIR>/bin/go test [something...] # test the new compiler
The same applies to other internal tools of the Go toolchain,
-such as asm
, cover
, link
,
-etc. Just recompile and install the tool using go
+such as asm
, cover
, link
, etc.
+Just recompile and install the tool using go
install
cmd/<TOOL>
and then use
the built Go binary to test it.
<GOCLONEDIR>/test
that contains
-several black-box and regression tests. The testsuite is run
+test suite in <GOCLONEDIR>/test
that contains
+several black-box and regression tests.
+The test suite is run
by all.bash
but you can also run it manually:
@@ -922,7 +1013,8 @@ Note that this will use the Go compiler found inPATH
.If you are contributing a change to a subrepository, obtain the -Go package using
@@ -945,7 +1037,8 @@ Unless explicitly told otherwise, such as in the discussion leading up to sending in the change, it's better not to specify a reviewer. All changes are automatically CC'ed to the golang-codereviews@googlegroups.com -mailing list. If this is your first ever change, there may be a moderation +mailing list. +If this is your first ever change, there may be a moderation delay before it appears on the mailing list, to prevent spam. @@ -995,8 +1088,8 @@ GitHub workflow this would be someone else attaching commits to a pull request). You can import these changes proposed by someone else into your local Git repository. On the Gerrit review page, click the "Download ▼" link in the upper right -corner, copy the "Checkout" command and run it from your local Git repo. It -should look something like this: +corner, copy the "Checkout" command and run it from your local Git repo. +It should look something like this:go get
. For example, to contribute +Go package usinggo get
. +For example, to contribute togolang.org/x/oauth2
, check out the code by running:@@ -1008,7 +1101,7 @@ To revert, change back to the branch you were working in. -Set up git aliases +
Set up git aliases
The
git-codereview
command can be run directly from the shell @@ -1030,7 +1123,8 @@ $ git syncThe
@@ -1047,16 +1141,22 @@ Git configuration file (usuallygit-codereview
subcommands have been chosen to be distinct from -Git's own, so it's safe to do so. To install them, copy this text into your +Git's own, so it's safe to do so. +To install them, copy this text into your Git configuration file (usually.gitconfig
in your home directory):.gitconfig
in your home directory):Sending multiple dependent changes
-Gerrit allows for changes to be dependent on each other, forming a dependency chain. +
+Gerrit allows for changes to be dependent on each other, forming a dependency chain. This is an indication for maintainers to better review your code, even though each -change will technically need to be approved and submitted separately.
+change will technically need to be approved and submitted separately. + -To submit a group of dependent changes, keep each change as a different commit under +
+To submit a group of dependent changes, keep each change as a different commit under the same branch, and then run: +
$ git codereview mail HEAD+Make sure to explicitly specify
+single changes. +HEAD
, which is usually not required when sending -single changes.