Pre commit/push hooks

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.

Let me know what your thoughts @mrjn and @ashwin95r are.

References - 1. http://stackoverflow.com/questions/427207/can-git-hook-scripts-be-managed-along-with-the-repository
2. Using Git Hooks to improve your workflow | by Pawan Rawal | Medium

1 Like

Sounds great! Simple and effective.

At some point, we’ll still need the Travis CI integration – but we can wait until v0.3 release. Think we already have a Trello card to track that task.

1 Like

Yes, we do have a card.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.