1*1c12ee1eSDan Willemsen# Contributing to Go Protocol Buffers 2*1c12ee1eSDan Willemsen 3*1c12ee1eSDan WillemsenGo protocol buffers is an open source project and accepts contributions. 4*1c12ee1eSDan WillemsenThe source of truth for this repository is at 5*1c12ee1eSDan Willemsen[go.googlesource.com/protobuf](https://go.googlesource.com/protobuf). 6*1c12ee1eSDan WillemsenThe code review tool used is 7*1c12ee1eSDan Willemsen[Gerrit Code Review](https://www.gerritcodereview.com/). 8*1c12ee1eSDan WillemsenAt this time, we are unfortunately unable to accept GitHub pull requests. 9*1c12ee1eSDan Willemsen 10*1c12ee1eSDan Willemsen 11*1c12ee1eSDan Willemsen## Becoming a contributor 12*1c12ee1eSDan Willemsen 13*1c12ee1eSDan WillemsenThe first step is to configure your environment. 14*1c12ee1eSDan WillemsenPlease follow the steps outlined in 15*1c12ee1eSDan Willemsen["Becoming a contributor" (golang.org)](https://golang.org/doc/contribute.html#contributor) 16*1c12ee1eSDan Willemsenas the setup for contributing to the `protobuf` project is identical 17*1c12ee1eSDan Willemsento that for contributing to the `go` project. 18*1c12ee1eSDan Willemsen 19*1c12ee1eSDan Willemsen 20*1c12ee1eSDan Willemsen## Before contributing code 21*1c12ee1eSDan Willemsen 22*1c12ee1eSDan WillemsenThe project welcomes submissions, but to make sure things are well coordinated 23*1c12ee1eSDan Willemsenwe ask that contributors discuss any significant changes before starting work. 24*1c12ee1eSDan WillemsenBest practice is to connect your work to the 25*1c12ee1eSDan Willemsen[issue tracker](https://github.com/golang/protobuf/issues), 26*1c12ee1eSDan Willemseneither by filing a new issue or by claiming an existing issue. 27*1c12ee1eSDan Willemsen 28*1c12ee1eSDan Willemsen 29*1c12ee1eSDan Willemsen## Sending a change via Gerrit 30*1c12ee1eSDan Willemsen 31*1c12ee1eSDan WillemsenThe `protobuf` project performs development in Gerrit. 32*1c12ee1eSDan WillemsenBelow are the steps to send a change using Gerrit. 33*1c12ee1eSDan Willemsen 34*1c12ee1eSDan Willemsen 35*1c12ee1eSDan Willemsen**Step 1:** Clone the Go source code: 36*1c12ee1eSDan Willemsen``` 37*1c12ee1eSDan Willemsen$ git clone https://go.googlesource.com/protobuf 38*1c12ee1eSDan Willemsen``` 39*1c12ee1eSDan Willemsen 40*1c12ee1eSDan Willemsen**Step 2:** Setup a Git hook: 41*1c12ee1eSDan WillemsenSetup a hook to run the tests prior to submitting changes to Gerrit: 42*1c12ee1eSDan Willemsen``` 43*1c12ee1eSDan Willemsen$ (cd protobuf/.git/hooks && echo -e '#!/bin/bash\n./test.bash' > pre-push && chmod a+x pre-push) 44*1c12ee1eSDan Willemsen``` 45*1c12ee1eSDan Willemsen 46*1c12ee1eSDan Willemsen**Step 3:** Prepare changes in a new branch, created from the `master` branch. 47*1c12ee1eSDan WillemsenTo commit the changes, use `git codereview change`; 48*1c12ee1eSDan Willemsenthat will create or amend a single commit in the branch. 49*1c12ee1eSDan Willemsen 50*1c12ee1eSDan Willemsen``` 51*1c12ee1eSDan Willemsen$ git checkout -b mybranch 52*1c12ee1eSDan Willemsen$ [edit files...] 53*1c12ee1eSDan Willemsen$ git add [files...] 54*1c12ee1eSDan Willemsen$ git codereview change # create commit in the branch 55*1c12ee1eSDan Willemsen$ [edit again...] 56*1c12ee1eSDan Willemsen$ git add [files...] 57*1c12ee1eSDan Willemsen$ git codereview change # amend the existing commit with new changes 58*1c12ee1eSDan Willemsen$ [etc.] 59*1c12ee1eSDan Willemsen``` 60*1c12ee1eSDan Willemsen 61*1c12ee1eSDan Willemsen**Step 4:** Send the changes for review to Gerrit using `git codereview mail`. 62*1c12ee1eSDan Willemsen``` 63*1c12ee1eSDan Willemsen$ git codereview mail # send changes to Gerrit 64*1c12ee1eSDan Willemsen``` 65*1c12ee1eSDan Willemsen 66*1c12ee1eSDan Willemsen**Step 5:** After a review, there may be changes that are required. 67*1c12ee1eSDan WillemsenDo so by applying changes to the same commit and mail them to Gerrit again: 68*1c12ee1eSDan Willemsen``` 69*1c12ee1eSDan Willemsen$ [edit files...] 70*1c12ee1eSDan Willemsen$ git add [files...] 71*1c12ee1eSDan Willemsen$ git codereview change # update same commit 72*1c12ee1eSDan Willemsen$ git codereview mail # send to Gerrit again 73*1c12ee1eSDan Willemsen``` 74*1c12ee1eSDan Willemsen 75*1c12ee1eSDan WillemsenWhen calling `git codereview mail`, it will call `git push` under the hood, 76*1c12ee1eSDan Willemsenwhich will trigger the test hook that was setup in step 2. 77*1c12ee1eSDan Willemsen 78*1c12ee1eSDan WillemsenThe [Contribution Guidelines](https://golang.org/doc/contribute.html) for the 79*1c12ee1eSDan WillemsenGo project provides additional details that are also relevant to 80*1c12ee1eSDan Willemsencontributing to the Go `protobuf` project. 81