I did my research on this and would like to share it with you guys and get your advice on it.
As I had suspected, there is no direct way to have repository wide hooks. Git hooks are installed in
.git/hooks directory. Even if we decide to centralize the code for hooks, we would have to make a
hooks directory in the DGraph repository. Then each developer would have to symlink this directory with the
.git/hooks directory on his machine.
I suggest we don’t need this for now. We could set up a pre-push hook on our individual machines. Pre-commit is also fine, but if you commit often and have small changes, you might not want to run the tests on every commit.
Setting up these hooks is a very easy.
You just have to make a file called
pre-push inside your
.git/hooks directory in your DGraph repo. Note the file is without any extension. Add the line
go test github.com/dgraph-io/dgraph/... to it.
Make the file executable. And Tada you have the hook setup. Now every time you try to push tests will be automatically run.
References - 1. http://stackoverflow.com/questions/427207/can-git-hook-scripts-be-managed-along-with-the-repository