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