views:

45

answers:

1

I'm currently looking to convert an existing SVN repository to git, and then to use Reviewboard for reviews before allowing pushes. I've only recently started using git and am far from an expert on it, however what I would like to do is have a pre-push hook which runs "post-review" to submit the changes to ReviewBoard. I have a hook working that will do this, however it looks like this is not propagated automatically to clones of the repository. Reading around it sounds like this isn't done to prevent forcing executable code on a user, however this is an internal-only repository and we want to enforce this and a few other policies. Is there a way to force git to propagate the hooks to remote clones or do we need to instruct our developers to run something that places those hooks in their local repos?

Thanks - Adam

+2  A: 

Git has no built-in support for transferring hooks between clones, optional or otherwise. It has default templates that you can modify or add to for new repositories, but those are pulled from the local filesystem (or network filesystem, as the case may be). It's possible that you could instrument a system for copying them, or put the hooks themselves into the repository and ask that developers configure their clone correctly.

It might also be possible to run the hook you want on the central bare repository, when the push happens but before the ref is updated. This could be done with a pre-receive or update hook. Whether this is acceptable depends on the actual functionality of this hook, which isn't clear from your post.

Reading http://www.reviewboard.org/docs/manual/dev/faq/ it sounds like maybe you should encourage your developers to use topic branches. Once changes are approved, they can be merged into release branches. You could have an update hook which only allows pushes to particular branches from privileged users, or any other criteria. This could also be done using Gitolite, which you can read about at http://progit.org/book/ch4-8.html

If you're not committed to Reviewboard, you might consider http://code.google.com/p/gerrit/ which is better integrated with Git and explicitly supports this workflow

cxreg