git-svn 的钩子 [英] Hooks for git-svn

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

问题描述

我可以为 git-svn 托管存储库的拉"/推"设置挂钩吗?

情况是我在 Google Code 上有一个项目宿主,并且使用 git 来管理本地工作副本.我想设置一些 hooks 以便在使用 git svn fetchgit svn dcommit 从/向 SVN 存储库签入/签出数据时,我可以对提交进行一些修改.由于我没有托管 SVN 存储库,因此无法在服务器端设置挂钩.

有什么我可以用的钩子吗?或者有没有办法标记"一个普通分支,以便该分支上的 git pullgit push 将从/向 SVN 存储库检入/检出,因此可以使用普通的 git hooks 吗?

提前致谢.

解决方案

如图所示 这个线程,你可以在 Subversion 端使用钩子,它实际上可以根据某些条件拒绝你的 git svn dcommit.

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

  • 如果中间存储库验证了您的推送,它可能会触发 git svn dcommit.
  • 它还可以在 git fetch 请求上触发 git svn fetch 并验证它,然后再允许您自己的 git fetch继续前进.

(两年后)

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天全站免登陆