| 
									
										
										
										
											2012-01-19 11:24:54 +11:00
										 |  |  | <!--{
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | 	"Title": "Contribution Guide" | 
					
						
							| 
									
										
										
										
											2012-01-19 11:24:54 +11:00
										 |  |  | }--> | 
					
						
							| 
									
										
										
										
											2009-10-23 15:24:08 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | 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. | 
					
						
							| 
									
										
										
										
											2014-12-12 13:53:29 +11:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2009-12-09 14:05:12 -08:00
										 |  |  | (Note that the <code>gccgo</code> frontend lives elsewhere; | 
					
						
							| 
									
										
										
										
											2009-11-06 14:15:41 -08:00
										 |  |  | see <a href="gccgo_contribute.html">Contributing to gccgo</a>.) | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-22 16:27:34 -07:00
										 |  |  | <p> | 
					
						
							|  |  |  | Sensitive security-related issues should be reported to <a href="mailto:security@golang.org">security@golang.org</a>. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h1 id="contributor">Becoming a contributor</h1> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-17 09:35:04 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Before you can contribute to the Go project you need to setup a few prerequisites. | 
					
						
							|  |  |  | The Go project uses <a href="https://www.gerritcodereview.com/">Gerrit</a>, an open | 
					
						
							|  |  |  | source online tool, to perform all code reviews. | 
					
						
							|  |  |  | Gerrit uses your email address as a unique identifier. | 
					
						
							|  |  |  | The Go project contributing flow is currently configured to work only with Google Accounts. | 
					
						
							|  |  |  | You must go through the following process <em>prior to contributing</em>. | 
					
						
							|  |  |  | You only need to do this once per Google Account. | 
					
						
							| 
									
										
										
										
											2014-03-17 09:35:04 +11:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-30 00:14:54 +05:30
										 |  |  | <h2 id="go-contrib-init">Automatically set up & diagnose your development environment</h2> | 
					
						
							| 
									
										
										
										
											2017-06-13 22:50:35 +00:00
										 |  |  | <p> | 
					
						
							|  |  |  |   The <code>go-contrib-init</code> tool configures and debugs your Go | 
					
						
							|  |  |  |   development environment, automatically performing many of the steps | 
					
						
							|  |  |  |   on this page, or telling you what you need to do next. If you wish | 
					
						
							|  |  |  |   to use it, run: | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							|  |  |  | $ go get -u golang.org/x/tools/cmd/go-contrib-init | 
					
						
							|  |  |  | $ cd /code/to/edit | 
					
						
							|  |  |  | $ go-contrib-init | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  |   The tool will either set things up, tell you that everything is | 
					
						
							|  |  |  |   configured, or tell you what steps you need to do manually. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h2 id="auth">Configure Git to use Gerrit</h2> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | You'll need a web browser and a command line terminal. | 
					
						
							|  |  |  | You should already have Git installed. | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Gerrit uses Google Accounts for authentication. | 
					
						
							|  |  |  | If you don't have a Google Account, you can create an account which | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | <a href="https://www.google.com/accounts/NewAccount">includes | 
					
						
							|  |  |  | a new Gmail email account</a> or create an account associated | 
					
						
							|  |  |  | <a href="https://accounts.google.com/SignUpWithoutGmail">with your existing | 
					
						
							|  |  |  | email address</a>. | 
					
						
							| 
									
										
										
										
											2009-11-06 10:33:46 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3>Step 1: Sign in to googlesource and generate a password</h3> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Visit <a href="https://go.googlesource.com">go.googlesource.com</a> | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | and click on "Generate Password" in the page's top right menu bar. | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | You will be redirected to accounts.google.com to sign in. | 
					
						
							| 
									
										
										
										
											2009-11-06 10:33:46 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3>Step 2: Run the provided script</h3> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | After signing in, you are taken to a page on go.googlesource.com with the title "Configure Git". | 
					
						
							|  |  |  | This page contains a personalized script which when run locally will configure git | 
					
						
							|  |  |  | to have your unique authentication key. | 
					
						
							|  |  |  | This key is paired with one generated server side similar to how ssh keys work. | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Copy and run this script locally in your command line terminal. | 
					
						
							|  |  |  | (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 | 
					
						
							|  |  |  | script as *nix.) | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-08-09 17:23:47 +05:30
										 |  |  | Your secret authentication token is now in a <code>.gitcookies</code> file | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | and Git is configured to use this file. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3 id="gerrit">Step 3: Register with Gerrit</h3> | 
					
						
							| 
									
										
										
										
											2009-12-09 14:05:12 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Now that you have your authentication token, you need to register your | 
					
						
							|  |  |  | account with Gerrit. | 
					
						
							|  |  |  | To do this, visit <a href="https://go-review.googlesource.com/login/"> | 
					
						
							|  |  |  | go-review.googlesource.com/login/</a>. | 
					
						
							|  |  |  | Sign in using the same Google Account you used above. | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h2 id="cla">Contributor License Agreement</h2> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h3 id="which_cla">Which CLA</h3> | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | 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. | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2015-08-03 10:15:52 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | <ul> | 
					
						
							|  |  |  | <li> | 
					
						
							|  |  |  | If you are the copyright holder, you will need to agree to the | 
					
						
							|  |  |  | <a href="https://developers.google.com/open-source/cla/individual">individual | 
					
						
							|  |  |  | contributor license agreement</a>, which can be completed online. | 
					
						
							|  |  |  | </li> | 
					
						
							|  |  |  | <li> | 
					
						
							|  |  |  | If your organization is the copyright holder, the organization | 
					
						
							|  |  |  | will need to agree to the | 
					
						
							|  |  |  | <a href="https://developers.google.com/open-source/cla/corporate">corporate | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | contributor license agreement</a>.<br> | 
					
						
							| 
									
										
										
										
											2015-08-03 10:15:52 -04:00
										 |  |  | </li> | 
					
						
							|  |  |  | </ul> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <i>If the copyright holder for your contribution has already completed the | 
					
						
							|  |  |  | agreement in connection with another Google open source project, | 
					
						
							|  |  |  | it does not need to be completed again.</i> | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h3 id="signing_cla">Completing the CLA</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | You can see your currently signed agreements and sign new ones through the Gerrit | 
					
						
							|  |  |  | interface. | 
					
						
							|  |  |  | To do this, <a href="https://go-review.googlesource.com/login/">Log into Gerrit</a>, | 
					
						
							| 
									
										
										
										
											2017-05-02 12:38:59 +02:00
										 |  |  | then visit the <a href="https://go-review.googlesource.com/settings/agreements">Agreements</a> | 
					
						
							|  |  |  | page. | 
					
						
							|  |  |  | If you do not have a signed agreement listed there, you can create one | 
					
						
							|  |  |  | by clicking "New Contributor Agreement" and following the steps. | 
					
						
							| 
									
										
										
										
											2015-08-03 10:15:52 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | 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 | 
					
						
							|  |  |  | completed and update the <code>AUTHORS</code> file. | 
					
						
							| 
									
										
										
										
											2015-08-03 10:15:52 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <span id="Code_review"></span> | 
					
						
							|  |  |  | <h1 id="prepare_dev_env">Preparing a Development Environment for Contributing</h1> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h2 id="git-codereview">Setting up Git for submission to Gerrit</h2> | 
					
						
							| 
									
										
										
										
											2016-01-06 15:23:47 -05:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Changes to Go must be reviewed before they are accepted, no matter who makes the change. | 
					
						
							|  |  |  | A custom git command called <code>git-codereview</code>, discussed below, | 
					
						
							|  |  |  | helps manage the code review process through a Google-hosted | 
					
						
							| 
									
										
										
										
											2017-08-09 08:11:34 -07:00
										 |  |  | <a href="https://go-review.googlesource.com/">instance</a> of Gerrit. | 
					
						
							| 
									
										
										
										
											2016-01-06 15:23:47 -05:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3 id="git-codereview_install">Install the git-codereview command</h3> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Install the <code>git-codereview</code> command by running, | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | $ go get -u golang.org/x/review/git-codereview | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-08 22:24:41 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | Make sure <code>git-codereview</code> is installed in your shell path, so that the | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <code>git</code> command can find it. Check that | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-18 12:55:22 +11:00
										 |  |  | $ git codereview help | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | </pre> | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-17 09:35:04 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | prints help text, not an error. | 
					
						
							| 
									
										
										
										
											2014-03-17 09:35:04 +11:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <p> | 
					
						
							|  |  |  | On Windows, when using git-bash you must make sure that | 
					
						
							|  |  |  | <code>git-codereview.exe</code> is in your git exec-path. | 
					
						
							|  |  |  | Run <code>git --exec-path</code> to discover the right location then create a | 
					
						
							| 
									
										
										
										
											2017-12-06 10:59:40 +01:00
										 |  |  | symbolic link or simply copy the executable from $GOPATH/bin to this directory. | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2016-02-17 10:46:30 -05:00
										 |  |  | <b>Note to Git aficionados:</b> | 
					
						
							|  |  |  | The <code>git-codereview</code> command is not required to | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | upload and manage Gerrit code reviews. | 
					
						
							|  |  |  | For those who prefer plain Git, the text below gives the Git equivalent of | 
					
						
							|  |  |  | each git-codereview command. | 
					
						
							| 
									
										
										
										
											2016-02-17 10:46:30 -05:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <p> | 
					
						
							|  |  |  | If you do use plain Git, note that you still need the commit hooks that the | 
					
						
							|  |  |  | git-codereview command configures; those hooks add a Gerrit | 
					
						
							|  |  |  | <code>Change-Id</code> line to the commit message and check that all Go source | 
					
						
							|  |  |  | files have been formatted with gofmt. | 
					
						
							|  |  |  | Even if you intend to use plain Git for | 
					
						
							|  |  |  | daily work, install the hooks in a new Git checkout by running | 
					
						
							|  |  |  | <code>git-codereview</code> <code>hooks</code>. | 
					
						
							| 
									
										
										
										
											2014-03-17 09:35:04 +11:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-06 15:23:47 -05:00
										 |  |  | <h3 id="git-config">Set up git aliases</h3> | 
					
						
							| 
									
										
										
										
											2013-06-05 21:09:43 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | The <code>git-codereview</code> command can be run directly from the shell | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | by typing, for instance, | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2013-06-05 21:09:43 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-18 12:55:22 +11:00
										 |  |  | $ git codereview sync | 
					
						
							| 
									
										
										
										
											2013-06-05 21:09:43 -07:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | but it is more convenient to set up aliases for <code>git-codereview</code>'s own | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | subcommands, so that the above becomes, | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2013-06-05 21:09:43 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | $ git sync | 
					
						
							| 
									
										
										
										
											2013-06-05 21:09:43 -07:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | <p> | 
					
						
							|  |  |  | The <code>git-codereview</code> subcommands have been chosen to be distinct from | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Git's own, so it's safe to do so. | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | The aliases are optional, but in the rest of this document we will assume | 
					
						
							|  |  |  | they are installed. | 
					
						
							|  |  |  | To install them, copy this text into your Git configuration file | 
					
						
							|  |  |  | (usually <code>.gitconfig</code> in your home directory): | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | [alias] | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | 	change = codereview change | 
					
						
							|  |  |  | 	gofmt = codereview gofmt | 
					
						
							|  |  |  | 	mail = codereview mail | 
					
						
							|  |  |  | 	pending = codereview pending | 
					
						
							|  |  |  | 	submit = codereview submit | 
					
						
							|  |  |  | 	sync = codereview sync | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <span id="help"></span> | 
					
						
							|  |  |  | <h3 id="understanding_git-codereview">Understanding the git-codereview command</h3> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | <p>After installing the <code>git-codereview</code> command, you can run</p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-18 12:55:22 +11:00
										 |  |  | $ git codereview help | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | </pre> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							|  |  |  | to learn more about its commands. | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | You can also read the <a href="https://godoc.org/golang.org/x/review/git-codereview">command documentation</a>. | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | <h1 id="making_a_contribution">Making a Contribution</h1> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h2 id="Design">Discuss your design</h2> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | The project welcomes submissions but please let everyone know what | 
					
						
							|  |  |  | you're working on if you want to change or add to the Go repositories. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | Before undertaking to write something new for the Go project, | 
					
						
							|  |  |  | please <a href="https://golang.org/issue/new">file an issue</a> | 
					
						
							|  |  |  | (or claim an <a href="https://golang.org/issues">existing issue</a>). | 
					
						
							|  |  |  | Significant changes must go through the | 
					
						
							|  |  |  | <a href="https://golang.org/s/proposal-process">change proposal process</a> | 
					
						
							|  |  |  | before they can be accepted. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | 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; | 
					
						
							|  |  |  | the code review tool is not the place for high-level discussions. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | When planning work, please note that the Go project follows a <a | 
					
						
							|  |  |  | href="https://golang.org/wiki/Go-Release-Cycle">six-month development cycle</a>. | 
					
						
							|  |  |  | 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 | 
					
						
							|  |  |  | sent during a feature freeze but will not be accepted until the freeze thaws. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-19 07:21:30 -07:00
										 |  |  | <h3 id="scratch">Not sure what change to make?</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | If you want to become familiar with Gerrit and the contribution process, | 
					
						
							|  |  |  | but aren't sure what you'd like to contribute just yet, you can use the <a | 
					
						
							|  |  |  | href="https://go.googlesource.com/scratch">scratch repository</a> to practice | 
					
						
							|  |  |  | making a change. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h2 id="making_a_change">Making a change</h2> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h3 id="checkout_go">Getting Go Source</h3> | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | First you need to have a local copy of the source checked out from the correct | 
					
						
							|  |  |  | repository. | 
					
						
							|  |  |  | As Go builds Go you will also likely need to have a working version | 
					
						
							|  |  |  | of Go installed (some documentation changes may not need this). | 
					
						
							|  |  |  | This should be a recent version of Go and can be obtained via any package or | 
					
						
							|  |  |  | binary distribution or you can build it from source. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | You should checkout the Go source repo anywhere you want as long as it's | 
					
						
							|  |  |  | outside of your $GOPATH. | 
					
						
							|  |  |  | Go to a directory where you want the source to appear and run the following | 
					
						
							|  |  |  | command in a terminal. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-03 18:57:40 -07:00
										 |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | $ git clone https://go.googlesource.com/go | 
					
						
							|  |  |  | $ cd go | 
					
						
							| 
									
										
										
										
											2017-05-03 18:57:40 -07:00
										 |  |  | </pre> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | <h3 id="master">Contributing to the main Go tree</h3> | 
					
						
							| 
									
										
										
										
											2012-06-05 00:55:45 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | Most Go installations use a release branch, but new changes should | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | only be made based on the master branch. <br> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | (They may be applied later to a release branch as part of the release process, | 
					
						
							|  |  |  | but most contributors won't do this themselves.) | 
					
						
							|  |  |  | Before making a change, make sure you start on the master branch: | 
					
						
							| 
									
										
										
										
											2012-06-05 00:55:45 +10:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | $ git checkout master | 
					
						
							|  |  |  | $ git sync | 
					
						
							| 
									
										
										
										
											2012-06-05 00:55:45 +10:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							|  |  |  | (In Git terms, <code>git</code> <code>sync</code> runs | 
					
						
							|  |  |  | <code>git</code> <code>pull</code> <code>-r</code>.) | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3 id="subrepos">Contributing to subrepositories (golang.org/x/...)</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | If you are contributing a change to a subrepository, obtain the | 
					
						
							|  |  |  | Go package using <code>go get</code>. For example, to contribute | 
					
						
							|  |  |  | to <code>golang.org/x/oauth2</code>, check out the code by running: | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							|  |  |  | $ go get -d golang.org/x/oauth2/... | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | Then, change your directory to the package's source directory | 
					
						
							|  |  |  | (<code>$GOPATH/src/golang.org/x/oauth2</code>). | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h3 id="change">Make your changes</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | The entire checked-out tree is editable. | 
					
						
							|  |  |  | Make your changes as you see fit ensuring that you create appropriate | 
					
						
							|  |  |  | tests along with your changes. Test your changes as you go. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h3 id="copyright">Copyright</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | Files in the Go repository don't list author names, both to avoid clutter | 
					
						
							|  |  |  | and to avoid having to keep the lists up to date. | 
					
						
							|  |  |  | Instead, your name will appear in the | 
					
						
							|  |  |  | <a href="https://golang.org/change">change log</a> and in the <a | 
					
						
							|  |  |  | href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file and perhaps the <a | 
					
						
							|  |  |  | href="/AUTHORS"><code>AUTHORS</code></a> file. | 
					
						
							| 
									
										
										
										
											2017-12-06 10:59:40 +01:00
										 |  |  | These files are automatically generated from the commit logs periodically. | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | The <a href="/AUTHORS"><code>AUTHORS</code></a> file defines who “The Go | 
					
						
							|  |  |  | Authors”—the copyright holders—are. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p>New files that you contribute should use the standard copyright header:</p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2018-01-01 02:04:51 +00:00
										 |  |  | // Copyright 2018 The Go Authors. All rights reserved. | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | // Use of this source code is governed by a BSD-style | 
					
						
							|  |  |  | // license that can be found in the LICENSE file. | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | Files in the repository are copyright the year they are added. | 
					
						
							|  |  |  | Do not update the copyright year on files that you change. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h3 id="commit_changes">Commit your changes</h3> | 
					
						
							| 
									
										
										
										
											2009-10-23 15:24:08 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-01 20:48:21 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Once you have edited files, you must tell Git that they have been modified. | 
					
						
							|  |  |  | You must also tell Git about any files that are added, removed, or renamed files. | 
					
						
							|  |  |  | These operations are done with the usual Git commands, | 
					
						
							|  |  |  | <code>git</code> <code>add</code>, | 
					
						
							|  |  |  | <code>git</code> <code>rm</code>, | 
					
						
							|  |  |  | and | 
					
						
							|  |  |  | <code>git</code> <code>mv</code>. | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-01 20:48:21 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Once you have the changes queued up, you will want to commit them. | 
					
						
							| 
									
										
										
										
											2017-05-03 18:57:40 -07:00
										 |  |  | In the Go contribution workflow this is done with a <code>git</code> | 
					
						
							|  |  |  | <code>change</code> command, which creates a local branch and commits the changes | 
					
						
							|  |  |  | directly to that local branch. | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-01 20:48:21 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 20:54:30 +00:00
										 |  |  | <p> | 
					
						
							|  |  |  | The workflow described here assumes a single change per branch. | 
					
						
							|  |  |  | It is also possible to prepare a sequence of (usually related) changes in a single branch. | 
					
						
							|  |  |  | See the <a href="https://golang.org/x/review/git-codereview">git-codereview documentation</a> for details. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | $ git change <i><branch></i> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							| 
									
										
										
										
											2009-11-01 20:48:21 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							|  |  |  | The name <i><branch></i> is an arbitrary one you choose to identify the | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | local branch containing your changes and will not be used elsewhere. | 
					
						
							|  |  |  | This is an offline operation and nothing will be sent to the server yet. | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-01 20:48:21 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							|  |  |  | (In Git terms, <code>git</code> <code>change</code> <code><branch></code> | 
					
						
							|  |  |  | runs <code>git</code> <code>checkout</code> <code>-b</code> <code>branch</code>, | 
					
						
							|  |  |  | then <code>git</code> <code>branch</code> <code>--set-upstream-to</code> <code>origin/master</code>, | 
					
						
							|  |  |  | then <code>git</code> <code>commit</code>.) | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-01 20:48:21 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-05-03 18:57:40 -07:00
										 |  |  | As the <code>git</code> <code>commit</code> is the final step, Git will open an | 
					
						
							|  |  |  | editor to ask for a commit message. (It uses the editor named by | 
					
						
							|  |  |  | the <code>$EDITOR</code> environment variable, | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <code>vi</code> by default.) | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | The file will look like: | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | # Please enter the commit message for your changes. Lines starting | 
					
						
							|  |  |  | # with '#' will be ignored, and an empty message aborts the commit. | 
					
						
							|  |  |  | # On branch foo | 
					
						
							|  |  |  | # Changes not staged for commit: | 
					
						
							|  |  |  | #	modified:   editedfile.go | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | At the beginning of this file is a blank line; replace it | 
					
						
							|  |  |  | with a thorough description of your change. | 
					
						
							| 
									
										
										
										
											2011-01-05 13:00:08 +11:00
										 |  |  | The first line of the change description is conventionally a one-line | 
					
						
							|  |  |  | summary of the change, prefixed by the primary affected package, | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | and is used as the subject for code review email. | 
					
						
							| 
									
										
										
										
											2016-05-25 00:12:22 +06:00
										 |  |  | It should complete the sentence "This change modifies Go to _____." | 
					
						
							|  |  |  | The rest of the description elaborates and should provide context for the | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | change and explain what it does. | 
					
						
							| 
									
										
										
										
											2016-05-25 00:12:22 +06:00
										 |  |  | Write in complete sentences with correct punctuation, just like | 
					
						
							|  |  |  | for your comments in Go. | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | If there is a helpful reference, mention it here. | 
					
						
							| 
									
										
										
										
											2016-05-25 00:12:22 +06:00
										 |  |  | If you've fixed an issue, reference it by number with a # before it. | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | After editing, the template might now read: | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2016-05-25 00:12:22 +06:00
										 |  |  | math: improve Sin, Cos and Tan precision for very large arguments | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | The existing implementation has poor numerical properties for | 
					
						
							|  |  |  | large arguments, so use the McGillicutty algorithm to improve | 
					
						
							|  |  |  | accuracy above 1e10. | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | The algorithm is described at http://wikipedia.org/wiki/McGillicutty_Algorithm | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Fixes #159 | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | # Please enter the commit message for your changes. Lines starting | 
					
						
							|  |  |  | # with '#' will be ignored, and an empty message aborts the commit. | 
					
						
							|  |  |  | # On branch foo | 
					
						
							|  |  |  | # Changes not staged for commit: | 
					
						
							|  |  |  | #	modified:   editedfile.go | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | The commented section of the file lists all the modified files in your client. | 
					
						
							| 
									
										
										
										
											2017-07-14 15:38:49 -06:00
										 |  |  | It is best to keep unrelated changes in different commits, | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | so if you see a file listed that should not be included, abort | 
					
						
							|  |  |  | the command and move that file to a different branch. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | The special notation "Fixes #159" associates the change with issue 159 in the | 
					
						
							|  |  |  | <a href="https://golang.org/issue/159">Go issue tracker</a>. | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | When this change is eventually applied, the issue | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | tracker will automatically mark the issue as fixed. | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | (There are several such conventions, described in detail in the | 
					
						
							|  |  |  | <a href="https://help.github.com/articles/closing-issues-via-commit-messages/">GitHub Issue Tracker documentation</a>.) | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Once you have finished writing the commit message, | 
					
						
							|  |  |  | save the file and exit the editor. | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <p> | 
					
						
							|  |  |  | You must have the $EDITOR environment variable set properly and working properly (exiting cleanly) | 
					
						
							|  |  |  | for this operation to succeed. | 
					
						
							|  |  |  | If you run into any issues at this step, it's likely your editor isn't exiting cleanly. | 
					
						
							|  |  |  | Try setting a different editor in your $EDITOR environment variable. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | If you wish to do more editing, re-stage your changes using | 
					
						
							|  |  |  | <code>git</code> <code>add</code>, and then run | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | $ git change | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | to update the change description and incorporate the staged changes. | 
					
						
							|  |  |  | The change description contains a <code>Change-Id</code> line near the bottom, | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | added by a Git commit hook during the initial | 
					
						
							|  |  |  | <code>git</code> <code>change</code>. | 
					
						
							|  |  |  | That line is used by Gerrit to match successive uploads of the same change. | 
					
						
							|  |  |  | Do not edit or delete it. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | (In Git terms, <code>git</code> <code>change</code> with no branch name | 
					
						
							|  |  |  | runs <code>git</code> <code>commit</code> <code>--amend</code>.) | 
					
						
							| 
									
										
										
										
											2014-12-18 11:42:25 +11:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3 id="Testing">Testing</h3> | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | You've <a href="code.html">written and tested your code</a>, but | 
					
						
							|  |  |  | before sending code out for review, run all the tests for the whole | 
					
						
							|  |  |  | tree to make sure the changes don't break other packages or programs: | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | $ cd go/src | 
					
						
							|  |  |  | $ ./all.bash | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | (To build under Windows use <code>all.bat</code>.) | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | After running for a while, the command should print | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | "ALL TESTS PASSED". | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3 id="mail">Send the change for review</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | Once the change is ready, send it for review. | 
					
						
							|  |  |  | This is similar to a <code>git push</code> in a GitHub style workflow. | 
					
						
							|  |  |  | This is done via the mail alias setup earlier which despite its name, doesn't | 
					
						
							|  |  |  | directly mail anything, it simply sends the change to Gerrit via git push. | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <pre> | 
					
						
							|  |  |  | $ git mail | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | (In Git terms, <code>git</code> <code>mail</code> pushes the local committed | 
					
						
							|  |  |  | changes to Gerrit using <code>git</code> <code>push</code> <code>origin</code> | 
					
						
							|  |  |  | <code>HEAD:refs/for/master</code>.) | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | If your change relates to an open issue, please add a comment to the issue | 
					
						
							| 
									
										
										
										
											2017-02-08 11:17:47 -08:00
										 |  |  | announcing your proposed fix, including a link to your change. | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | The code review server assigns your change an issue number and URL, | 
					
						
							|  |  |  | which <code>git</code> <code>mail</code> will print, something like: | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | remote: New Changes: | 
					
						
							|  |  |  | remote:   https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3>Troubleshooting</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | The most common way that the <code>git mail</code> command fails is because the | 
					
						
							|  |  |  | email address used has not gone through the setup above. | 
					
						
							|  |  |  | <br> | 
					
						
							|  |  |  | If you see something like... | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							|  |  |  | remote: Processing changes: refs: 1, done | 
					
						
							|  |  |  | remote: | 
					
						
							|  |  |  | remote: ERROR:  In commit ab13517fa29487dcf8b0d48916c51639426c5ee9 | 
					
						
							|  |  |  | remote: ERROR:  author email address XXXXXXXXXXXXXXXXXXX | 
					
						
							|  |  |  | remote: ERROR:  does not match your user account. | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | You need to either add the email address listed to the CLA or set this repo to use | 
					
						
							|  |  |  | another email address already approved. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | First let's change the email address for this repo so this doesn't happen again. | 
					
						
							|  |  |  | You can change your email address for this repo with the following command: | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							|  |  |  | $ git config user.email email@address.com | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | Then change the previous commit to use this alternative email address. | 
					
						
							|  |  |  | You can do that with: | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							|  |  |  | $ git commit --amend --author="Author Name <email@address.com>" | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | Finally try to resend with: | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							|  |  |  | $ git mail | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h3 id="cc">Specifying a reviewer / CCing others</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | Unless explicitly told otherwise, such as in the discussion leading | 
					
						
							| 
									
										
										
										
											2017-07-14 15:38:49 -06:00
										 |  |  | up to sending in the change, it's better not to specify a reviewer. | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | All changes are automatically CC'ed to the | 
					
						
							|  |  |  | <a href="https://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a> | 
					
						
							|  |  |  | 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. | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | You can specify a reviewer or CC interested parties | 
					
						
							|  |  |  | using the <code>-r</code> or <code>-cc</code> options. | 
					
						
							|  |  |  | Both accept a comma-separated list of email addresses: | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							|  |  |  | $ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <h2 id="review">Going through the review process</h2> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Running <code>git</code> <code>mail</code> will send an email to you and the | 
					
						
							|  |  |  | reviewers asking them to visit the issue's URL and make comments on the change. | 
					
						
							|  |  |  | When done, the reviewer adds comments through the Gerrit user interface | 
					
						
							|  |  |  | and clicks "Reply" to send comments back. | 
					
						
							|  |  |  | You will receive a mail notification when this happens. | 
					
						
							| 
									
										
										
										
											2017-10-04 00:02:37 -04:00
										 |  |  | You may reply through the web interface or | 
					
						
							|  |  |  | <a href="https://gerrit-review.googlesource.com/Documentation/intro-user.html#reply-by-email">via email</a>. | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3 id="revise">Revise and resend</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							|  |  |  | The Go contribution workflow is optimized for iterative revisions based on | 
					
						
							|  |  |  | feedback. | 
					
						
							|  |  |  | It is rare that an initial contribution will be ready to be applied as is. | 
					
						
							|  |  |  | As you revise your contribution and resend Gerrit will retain a history of | 
					
						
							|  |  |  | all the changes and comments made in the single URL. | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-10-04 00:02:37 -04:00
										 |  |  | You may respond to review comments through the web interface or | 
					
						
							|  |  |  | <a href="https://gerrit-review.googlesource.com/Documentation/intro-user.html#reply-by-email">via email</a>. | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | When you have revised the code and are ready for another round of review, | 
					
						
							|  |  |  | stage those changes and use <code>git</code> <code>change</code> to update the | 
					
						
							|  |  |  | commit. | 
					
						
							| 
									
										
										
										
											2017-07-14 15:38:49 -06:00
										 |  |  | To send the updated change for another round of review, | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | run <code>git</code> <code>mail</code> again. | 
					
						
							| 
									
										
										
										
											2014-07-03 17:42:23 -04:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | The reviewer can comment on the new copy, and the process repeats. | 
					
						
							|  |  |  | The reviewer approves the change by giving it a positive score | 
					
						
							|  |  |  | (+1 or +2) and replying <code>LGTM</code>: looks good to me. | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 14:08:42 -05:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | You can see a list of your pending changes by running <code>git</code> | 
					
						
							|  |  |  | <code>pending</code>, and switch between change branches with <code>git</code> | 
					
						
							|  |  |  | <code>change</code> <code><i><branch></i></code>. | 
					
						
							| 
									
										
										
										
											2013-02-28 13:32:36 -08:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-06 15:23:47 -05:00
										 |  |  | <h3 id="sync">Synchronize your client</h3> | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | While you were working, others might have submitted changes to the repository. | 
					
						
							|  |  |  | To update your local branch, run | 
					
						
							| 
									
										
										
										
											2013-01-18 14:08:42 -05:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | $ git sync | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-14 14:32:56 +08:00
										 |  |  | (In git terms, <code>git</code> <code>sync</code> runs | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <code>git</code> <code>pull</code> <code>-r</code>.) | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h3 id="resolving_conflicts">Resolving Conflicts</h3> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | If files you were editing have changed, Git does its best to merge the | 
					
						
							|  |  |  | remote changes into your local changes. | 
					
						
							|  |  |  | It may leave some files to merge by hand. | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <p> | 
					
						
							|  |  |  | For example, suppose you have edited <code>sin.go</code> but | 
					
						
							|  |  |  | someone else has committed an independent change. | 
					
						
							|  |  |  | When you run <code>git</code> <code>sync</code>, | 
					
						
							|  |  |  | you will get the (scary-looking) output: | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | $ git sync | 
					
						
							|  |  |  | Failed to merge in the changes. | 
					
						
							|  |  |  | Patch failed at 0023 math: improved Sin, Cos and Tan precision for very large arguments | 
					
						
							|  |  |  | The copy of the patch that failed is found in: | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  |    /home/you/repo/.git/rebase-apply/patch | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | When you have resolved this problem, run "git rebase --continue". | 
					
						
							|  |  |  | If you prefer to skip this patch, run "git rebase --skip" instead. | 
					
						
							|  |  |  | To check out the original branch and stop rebasing, run "git rebase --abort". | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | If this happens, run | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <pre> | 
					
						
							|  |  |  | $ git status | 
					
						
							|  |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | to see which files failed to merge. | 
					
						
							|  |  |  | The output will look something like this: | 
					
						
							|  |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | rebase in progress; onto a24c3eb | 
					
						
							|  |  |  | You are currently rebasing branch 'mcgillicutty' on 'a24c3eb'. | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  |   (fix conflicts and then run "git rebase --continue") | 
					
						
							|  |  |  |   (use "git rebase --skip" to skip this patch) | 
					
						
							|  |  |  |   (use "git rebase --abort" to check out the original branch) | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | Unmerged paths: | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  |   (use "git reset HEAD <file>..." to unstage) | 
					
						
							|  |  |  |   (use "git add <file>..." to mark resolution) | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | 	<i>both modified: sin.go</i> | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | The only important part in that transcript is the italicized "both modified" | 
					
						
							|  |  |  | line: Git failed to merge your changes with the conflicting change. | 
					
						
							|  |  |  | When this happens, Git leaves both sets of edits in the file, | 
					
						
							|  |  |  | with conflicts marked by <code><<<<<<<</code> and | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | <code>>>>>>>></code>. | 
					
						
							| 
									
										
										
										
											2014-07-07 16:31:20 +10:00
										 |  |  | It is now your job to edit the file to combine them. | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Continuing the example, searching for those strings in <code>sin.go</code> | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | might turn up: | 
					
						
							|  |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 	arg = scale(arg) | 
					
						
							|  |  |  | <<<<<<< HEAD | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | 	if arg < 1e9 { | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | ======= | 
					
						
							| 
									
										
										
										
											2015-10-05 21:15:23 -06:00
										 |  |  | 	if arg < 1e10 { | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | >>>>>>> mcgillicutty | 
					
						
							|  |  |  | 		largeReduce(arg) | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Git doesn't show it, but suppose the original text that both edits | 
					
						
							|  |  |  | started with was 1e8; you changed it to 1e10 and the other change to 1e9, | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | so the correct answer might now be 1e10. | 
					
						
							|  |  |  | First, edit the section to remove the markers and leave the correct code: | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 	arg = scale(arg) | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | 	if arg < 1e10 { | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | 		largeReduce(arg) | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Then tell Git that the conflict is resolved by running | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-09 14:05:12 -08:00
										 |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | $ git add sin.go | 
					
						
							| 
									
										
										
										
											2009-12-09 14:05:12 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | <p> | 
					
						
							| 
									
										
										
										
											2009-11-08 21:08:27 -08:00
										 |  |  | If you had been editing the file, say for debugging, but do not | 
					
						
							|  |  |  | care to preserve your changes, you can run | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | <code>git</code> <code>reset</code> <code>HEAD</code> <code>sin.go</code> | 
					
						
							|  |  |  | to abandon your changes. | 
					
						
							|  |  |  | Then run <code>git</code> <code>rebase</code> <code>--continue</code> to | 
					
						
							|  |  |  | restore the change commit. | 
					
						
							| 
									
										
										
										
											2009-11-07 18:56:00 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-06 15:23:47 -05:00
										 |  |  | <h3 id="download">Reviewing code by others</h3> | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | As part of the review process reviewers can propose changes directly (in the | 
					
						
							|  |  |  | 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. | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | On the Gerrit review page, click the "Download â–¼" link in the upper right | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | corner, copy the "Checkout" command and run it from your local Git repo. It | 
					
						
							|  |  |  | should look something like this: | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <pre> | 
					
						
							| 
									
										
										
										
											2015-02-24 21:33:29 -08:00
										 |  |  | $ git fetch https://go.googlesource.com/review refs/changes/21/1221/1 && git checkout FETCH_HEAD | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </pre> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | To revert, change back to the branch you were working in. | 
					
						
							| 
									
										
										
										
											2013-02-15 14:01:12 +11:00
										 |  |  | </p> | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h2 id="submit">Apply the change to the master branch</h2> | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | After the code has been <code>LGTM</code>'ed, an approver may | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | apply it to the master branch using the Gerrit UI. | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | There is a "Submit" button on the web page for the change | 
					
						
							|  |  |  | that appears once the change is approved (marked +2). | 
					
						
							| 
									
										
										
										
											2009-11-06 10:04:22 -08:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | <p> | 
					
						
							|  |  |  | This checks the change into the repository. | 
					
						
							|  |  |  | The change description will include a link to the code review, | 
					
						
							|  |  |  | and the code review will be updated with a link to the change | 
					
						
							|  |  |  | in the repository. | 
					
						
							| 
									
										
										
										
											2014-12-10 09:29:35 +11:00
										 |  |  | Since the method used to integrate the changes is "Cherry Pick", | 
					
						
							|  |  |  | the commit hashes in the repository will be changed by | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | the "Submit" operation. | 
					
						
							| 
									
										
										
										
											2013-02-10 19:40:33 -05:00
										 |  |  | </p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | <h2 id="more">More information</h2> | 
					
						
							| 
									
										
										
										
											2014-04-25 20:09:04 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | <p> | 
					
						
							| 
									
										
										
										
											2017-02-09 15:33:13 -05:00
										 |  |  | In addition to the information here, the Go community maintains a <a | 
					
						
							|  |  |  | href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page. | 
					
						
							| 
									
										
										
										
											2014-04-25 20:09:04 -07:00
										 |  |  | Feel free to contribute to this page as you learn the review process. | 
					
						
							|  |  |  | </p> |