Hooks for git-svn
git, git-svn, hook, version-control
Solution
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.
(2 years later)
David Souther proposes a solution in his blog (April 2012)
The solution I have is to have a repository with split heads. Most of the time, the intermediate repository will have an empty working directory. When a push happens, it will check out master, verify the build, and push to svn, before returning to the empty branch.
We’re going to set up an intermediate git repo with two branches.
- master will still point to the SVN repo,
- and the new branch `stage` will let us keep the working directory clean and in sync with downstream changes.
Check out his gist.
Problem
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.