Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
514 views
in Technique[技术] by (71.8m points)

version control - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...