挂git-svn [英] Hooks for git-svn

查看:97
本文介绍了挂git-svn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b $是否可以设置钩子以拉/推到 git-svn 托管存储库? b

这种情况是我在 Google Code 上拥有项目主持人,并使用git来管理本地工作副本。我想设置一些钩子,以便在使用 git svn fetch git svn dcommit ,我可以对提交做一些修改。因为我没有托管SVN仓库,所以我无法在服务器端设置钩子。



有没有我可以使用的钩子?或者是否有办法标记一个普通的分支,以便该分支上的 git pull git push 会检入/出SVN存储库,因此可以使用正常的git钩子?



预先感谢。

解决方案

所示这个线程,您可以在Subversion端拥有钩子,它可以根据一些标准实际拒绝您的 git svn dcommit



但是如果你需要Git端的git钩子,我会建议设置一个中间的 裸露 Git存储库(裸便于推/拉)。
在裸露的回购中,您可以有任何你需要的钩子,如我如何通过git push将多个分支部署到不同的目录?(不是关于svn,而是在这里详细说明一个额外的repo的类似设置)




  • 如果中间回购确认您的推送,它可能触发 git svn dcommit
  • 它也可以在 git fetch 请求中触发一个 git svn fetch 并验证它,然后才允许您自己的 git fetch 前进。





(2年后)

David Souther 他的博客(2012年4月)


我的解决方案是拥有一个包含分割头的存储库。大多数情况下,中间存储库将有一个空的工作目录。当发生推送时,它会检出master,验证构建,并推送到svn,然后返回到空分支。



我们将设置一个包含两个分支的中间git仓库。




  • master仍然会指向SVN仓库,
  • 和新分支 stage 将让我们保持工作目录的清洁和与下游更改同步。


查看他的要点


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.

解决方案

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.

这篇关于挂git-svn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆