views:

551

answers:

2
+3  Q: 

Hooks for git-svn

Can I set hooks for "pull"/"push"ing from/to a git-svn managed repository?

The situation is that I have a project host on Google Code, and use git to manage the local working copy. I want to set some hooks so that when checking in/out data from/to the SVN repository with git svn fetch and git svn dcommit, I can do some modification to the commit. Since I do not host the SVN repository, I can't set hooks on the server side.

Is there any hook I could use? Or is there a way to "mark" an ordinary branch, so that git pull and git push on that branch will check in/out from/to a SVN repository instead, therefore the normal git hooks could be used?

Thanks in advance.

+4  A: 

As illustrated by this thread, you can have hooks on the Subversion side which can actually reject your git svn dcommit based on some criteria.

But if you need git hooks on the Git side, I would recommend setting up an intermediate bare Git repository (bare for easy push/pull).
On that bare repo, you can have any hook you need, as shown in "how do I deploy multiple branches to different directories via git push?" (not about svn but just here to detail a similar setup of an extra repo)

  • if the intermediate repo validate your push, it could trigger the git svn dcommit.
  • it can also, on a git fetch request, trigger a git svn fetch and validate it, before allowing your own git fetch to move forward.
VonC
Brilliant! An intermediate repository will solve my problem. But I'd like to keep the question open for a few days to see if there is a more elegant solution :)
Iamamac
@lamamac: absolutely. That is what a bounty is for ;)
VonC
A: 

There's a git-remote-cvs remote helper in the works; presumably someone will do the same for svn. Normal hooks for remote operations should be invoked before and after calling these helpers.

Tobu