1# Contributing 2 31. [Install Go](https://golang.org/dl/). 4 1. Ensure that your `GOBIN` directory (by default `$(go env GOPATH)/bin`) 5 is in your `PATH`. 6 1. Check it's working by running `go version`. 7 * If it doesn't work, check the install location, usually 8 `/usr/local/go`, is on your `PATH`. 9 101. Sign one of the 11[contributor license agreements](#contributor-license-agreements) below. 12 131. Run `go get golang.org/x/review/git-codereview` to install the code reviewing tool. 14 15 1. Ensure it's working by running `git codereview` (check your `PATH` if 16 not). 17 18 1. If you would like, you may want to set up aliases for `git-codereview`, 19 such that `git codereview change` becomes `git change`. See the 20 [godoc](https://godoc.org/golang.org/x/review/git-codereview) for details. 21 22 * Should you run into issues with the `git-codereview` tool, please note 23 that all error messages will assume that you have set up these aliases. 24 251. Change to a directory of your choosing and clone the repo. 26 27 ``` 28 cd ~/code 29 git clone https://code.googlesource.com/google-api-go-client 30 ``` 31 32 * If you have already checked out the source, make sure that the remote 33 `git` `origin` is https://code.googlesource.com/google-api-go-client: 34 35 ``` 36 git remote -v 37 # ... 38 git remote set-url origin https://code.googlesource.com/google-api-go-client 39 ``` 40 41 * The project uses [Go Modules](https://blog.golang.org/using-go-modules) 42 for dependency management See 43 [`gopls`](https://github.com/golang/go/wiki/gopls) for making your editor 44 work with modules. 45 461. Change to the project directory: 47 48 ``` 49 cd ~/code/google-api-go-client 50 ``` 51 521. Make sure your `git` auth is configured correctly by visiting 53https://code.googlesource.com, clicking "Generate Password" at the top-right, 54and following the directions. Otherwise, `git codereview mail` in the next step 55will fail. 56 571. Now you are ready to make changes. Don't create a new branch or make commits in the traditional 58way. Use the following`git codereview` commands to create a commit and create a Gerrit CL: 59 60 ``` 61 git codereview change <branch-name> # Use this instead of git checkout -b <branch-name> 62 # Make changes. 63 git add ... 64 git codereview change # Use this instead of git commit 65 git codereview mail # If this fails, the error message will contain instructions to fix it. 66 ``` 67 68 * This will create a new `git` branch for you to develop on. Once your 69 change is merged, you can delete this branch. 70 711. As you make changes for code review, ammend the commit and re-mail the 72change: 73 74 ``` 75 # Make more changes. 76 git add ... 77 git codereview change 78 git codereview mail 79 ``` 80 81 * **Warning**: do not change the `Change-Id` at the bottom of the commit 82 message - it's how Gerrit knows which change this is (or if it's new). 83 84 * When you fixes issues from code review, respond to each code review 85 message then click **Reply** at the top of the page. 86 87 * Each new mailed amendment will create a new patch set for 88 your change in Gerrit. Patch sets can be compared and reviewed. 89 90 * **Note**: if your change includes a breaking change, our breaking change 91 detector will cause CI/CD to fail. If your breaking change is acceptable 92 in some way, add a `BREAKING_CHANGE_ACCEPTABLE=<reason>` line to the commit 93 message to cause the detector not to be run and to make it clear why that is 94 acceptable. 95 961. Finally, add reviewers to your CL when it's ready for review. Reviewers will 97not be added automatically. If you're not sure who to add for your code review, 98add deklerk@, tbp@, cbro@, and codyoss@. 99 100## Contributor License Agreements 101 102Before we can accept your pull requests you'll need to sign a Contributor 103License Agreement (CLA): 104 105- **If you are an individual writing original source code** and **you own the 106intellectual property**, then you'll need to sign an [individual CLA][indvcla]. 107- **If you work for a company that wants to allow you to contribute your 108work**, then you'll need to sign a [corporate CLA][corpcla]. 109 110You can sign these electronically (just scroll to the bottom). After that, 111we'll be able to accept your pull requests. 112 113## Contributor Code of Conduct 114 115As contributors and maintainers of this project, 116and in the interest of fostering an open and welcoming community, 117we pledge to respect all people who contribute through reporting issues, 118posting feature requests, updating documentation, 119submitting pull requests or patches, and other activities. 120 121We are committed to making participation in this project 122a harassment-free experience for everyone, 123regardless of level of experience, gender, gender identity and expression, 124sexual orientation, disability, personal appearance, 125body size, race, ethnicity, age, religion, or nationality. 126 127Examples of unacceptable behavior by participants include: 128 129* The use of sexualized language or imagery 130* Personal attacks 131* Trolling or insulting/derogatory comments 132* Public or private harassment 133* Publishing other's private information, 134such as physical or electronic 135addresses, without explicit permission 136* Other unethical or unprofessional conduct. 137 138Project maintainers have the right and responsibility to remove, edit, or reject 139comments, commits, code, wiki edits, issues, and other contributions 140that are not aligned to this Code of Conduct. 141By adopting this Code of Conduct, 142project maintainers commit themselves to fairly and consistently 143applying these principles to every aspect of managing this project. 144Project maintainers who do not follow or enforce the Code of Conduct 145may be permanently removed from the project team. 146 147This code of conduct applies both within project spaces and in public spaces 148when an individual is representing the project or its community. 149 150Instances of abusive, harassing, or otherwise unacceptable behavior 151may be reported by opening an issue 152or contacting one or more of the project maintainers. 153 154This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, 155available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) 156 157[indvcla]: https://developers.google.com/open-source/cla/individual 158[corpcla]: https://developers.google.com/open-source/cla/corporate 159