Bläddra i källkod

CONTRIBUTING.md: add pre-push hook instructions

Now that we have a test.bash script that does comprehensive testing,
add instructions to CONTRIBUTING.md for how to install the hook.

We use a pre-push hook, rather than a pre-commit hook (which is more common)
since we're more interested in making sure the changes are correct just prior
to a user sending out code for review.

It is common for a user to continually add new files and/or update the commit
message. It would be annoying running the tests for every one of those operations.

Change-Id: I084a74fdb7f601d8075b3e349c7ee854b3b9394b
Reviewed-on: https://go-review.googlesource.com/128364
Reviewed-by: Herbie Ong <herbie@google.com>
Joe Tsai 7 år sedan
förälder
incheckning
dd8f2fa63e
1 ändrade filer med 13 tillägg och 4 borttagningar
  1. 13 4
      CONTRIBUTING.md

+ 13 - 4
CONTRIBUTING.md

@@ -35,10 +35,16 @@ Below are the steps to send a change using Gerrit.
 
 **Step 1:** Clone the Go source code:
 ```
-git clone https://go.googlesource.com/protobuf
+$ git clone https://go.googlesource.com/protobuf
 ```
 
-**Step 2:** Prepare changes in a new branch, created from the `master` branch.
+**Step 2:** Setup a Git hook:
+Setup a hook to run the tests prior to submitting changes to Gerrit:
+```
+$ (cd protobuf/.git/hooks && echo -e '#!/bin/bash\n./test.bash' > pre-push && chmod a+x pre-push)
+```
+
+**Step 3:** Prepare changes in a new branch, created from the `master` branch.
 To commit the changes, use `git codereview change`;
 that will create or amend a single commit in the branch.
 
@@ -53,12 +59,12 @@ $ git codereview change   # amend the existing commit with new changes
 $ [etc.]
 ```
 
-**Step 3:** Send the changes for review to Gerrit using `git codereview mail`.
+**Step 4:** Send the changes for review to Gerrit using `git codereview mail`.
 ```
 $ git codereview mail     # send changes to Gerrit
 ```
 
-**Step 4:** After a review, there may be changes that are required.
+**Step 5:** After a review, there may be changes that are required.
 Do so by applying changes to the same commit and mail them to Gerrit again:
 ```
 $ [edit files...]
@@ -67,6 +73,9 @@ $ git codereview change   # update same commit
 $ git codereview mail     # send to Gerrit again
 ```
 
+When calling `git codereview mail`, it will call `git push` under the hood,
+which will trigger the test hook that was setup in step 2.
+
 The [Contribution Guidelines](https://golang.org/doc/contribute.html) for the
 Go project provides additional details that are also relevant to
 contributing to the Go `protobuf` project.