如何在循环中运行svn update以将提交导入git?

时间:2011-12-05 17:59:54

标签: git svn version-control git-svn revision

当前设置
我正在运行本地 git 存储库并行到同一文件夹中的 svn 结帐。每当 svn 服务器上发生新事件时,我都会运行svn update来下载提交。然后我git add && git commit git 存储库进行的整套更改。

任务
我想分别检查每个提交,以便能够使用来自 svn 的相应提交消息进行git add && git commit更改。


我已经发现我可以使用svnversion来检索工作副本和服务器的修订号。

// svnversion -h
usage: svnversion [OPTIONS] [WC_PATH [TRAIL_URL]]

  Produce a compact 'version number' for the working copy path
  WC_PATH.  TRAIL_URL is the trailing portion of the URL used to
  determine if WC_PATH itself is switched (detection of switches
  within WC_PATH does not rely on TRAIL_URL).  The version number
  is written to standard output.  For example:

    $ svnversion . /repos/svn/trunk
    4168

  The version number will be a single number if the working
  copy is single revision, unmodified, not switched and with
  an URL that matches the TRAIL_URL argument.  If the working
  copy is unusual the version number will be more complex:

   4123:4168     mixed revision working copy
   4168M         modified working copy
   4123S         switched working copy
   4123P         partial working copy, from a sparse checkout
   4123:4168MS   mixed revision, modified, switched working copy

   ...

注意
我很乐意和你讨论解决问题的想法 稍后的设置还包括 svn externals ,这就是我无法通过 git-svn 签出 svn 存储库的原因。

3 个答案:

答案 0 :(得分:3)

您可能还需要调查两个选项:

  1. SmartGit

    SmartGit是Subversion + Git客户端,这意味着SmartGit可以与本地Git存储库一起使用,但是您可以将svn存储库添加为远程(类似于git远程控制器)。 SmartGit比git-svn功能更优越。有关详细信息,请参阅SmartGit vs. git-svn comparison

    特别是SmartGit确实支持git子模块和svn外部,所以你甚至可以混合它们。

    SmartGit是专有软件,但它可以免费用于非商业用途。

  2. SubGit

    SubGit是服务器端解决方案。这意味着您必须安装SubGit并将其连接到您的Subversion存储库,该存储库基本上包括两个步骤:

    1. 通过SubGit将SVN存储库初始翻译为新创建的Git存储库。

    2. 安装在每个git push上触发的SubGit特定挂钩,这样每个更改都会在Git和SVN存储库之间同步。

  3. 有关详细信息,请参阅SubGit documentation

    SubGit是专有软件。 SubGit对于拥有多达10个提交者以及学术和开源项目的小型团队是免费的。  SubGit也可作为Bitbucket服务器的附件提供,以便查看更多信息here

    声明:
    我是SubGit开发人员,我与SmartGit开发人员密切联系。但这两个项目似乎与您的具体案例非常相关。希望你能发现我的评论有用。

答案 1 :(得分:2)

您可以尝试git svn,其唯一目的是同时与SVN和Git合作。

不要直接使用svn。以下是设置和使用SVN和Git所需的全部内容。

http://progit.org/book/ch8-1.html

答案 2 :(得分:0)

我曾经创建了一个像shell脚本一样的“持续集成”,基本上是

while true
do
  sleep 42
  if svn up | grep '^. ' | egrep '^[ABDUCGE]*'
  # the first grep drops the "At revision xxx" line
  # the second grep searches for the update status codes
  then
    #do something
  fi
done

但我只是从记忆中写下这个,也许还有其他一些svn up可能产生的消息。