混帐SVN:自动导入/创建svn的修订版的Git标签

编程入门 行业动态 更新时间:2024-10-15 08:25:10
本文介绍了混帐SVN:自动导入/创建svn的修订版的Git标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Git SVN的svn库工作。 git的主分支镜像主干分支(使用的唯一SVN分支),即有一个对svn到主分支和主干分支元件之间的一个关系。

I am using git-svn to work with a svn repository. The git master branch is mirroring the svn trunk branch (the only svn branch in use), i.e. there is a one to one relation between elements on the master branch and the trunk branch.

我想有一个对应于svn的版本的Git标签,这样我可以这样做,例如 git的差异R123 workbranch 的东西,看看有什么我都比较SVN做修订123。

I want to have git tags that corresponds to svn revisions, so that I can do things like for instance git diff r123 workbranch to see what I have done compared to svn revision 123.

当我这样做混帐SVN变基的修订没有标记,所以我创建了我运行后SVN底垫下面的脚本:

The revisions are not tagged when I do git svn rebase, so I have created the following script that I run post svn rebase:

#!/usr/bin/perl use strict; use warnings; open(PIPE, "git log master |"); # Format for the pipe output: # ... # commit 6b24b8fdc6a25d35b01140dc1ac054697133423d # ... # git-svn-id: server.example/svn/project/trunk@594 164096ca-3471-41d1-a9ce-9541462a8c31 # ... my $commit = ""; my $i = 0; foreach my $line (<PIPE>) { if ($line =~ /^commit ([\da-f]+)/) { $commit = $1; next; } next unless $line =~ /^\s+git-svn-id: .*\/trunk\@(\d+) /; my $git_svn_id = $1; run("git", "tag", "-f", "r$git_svn_id", $commit); last if $i++ == 20; } close(PIPE); sub run { print join(' ', @_), "\n"; return system(@_); }

该脚本可以完成任务,但我必须每次手动运行它,我已经(任意)上限它在检查过去的21修订所以缺少一些(但我会看到,从理论上的风险印刷)。

This script gets the job done, but I have to run it manually every time, and I have (arbitrarily) capped it at checking the last 21 revisions so there is a theoretical risk of missing some (but I will see that from the printing).

问题:有什么办法可以自动执行此让我就跑混帐SVN变基键,全部采用进口版本将被标记的混帐?任何挂钩我可以使用?

The question: Is there any way I can automate this so that I just run git svn rebase and all imported revisions will be tagged in git? Any hooks I can use?

PS是的,我知道SVN的发现-​​REV,但我想绝对不必编写命令一样复杂 git的差异$(GIT SVN找到-REV R123)$(GIT SVN找到-REV R124没办法),而不是仅仅 git的差异R123 R124 。

推荐答案

下面是一个疯狂的想法:陷阱庆典命令,并自动更换任何 r1234 与SHA哈希的字符串:

Here's a crazy idea: Trap bash commands and automatically replace any r1234 strings with SHA hashes:

shopt -s extdebug enhance_rev_parse () { [ -n "$COMP_LINE" ] && return # do nothing if completing case "$BASH_COMMAND" in *r[0-9]*) eval $(echo "$BASH_COMMAND" | sed -e 's/r[0-9][0-9]*/$(git svn find-rev &)/g') return 1 ;; esac } trap 'enhance_rev_parse' DEBUG

更多推荐

混帐SVN:自动导入/创建svn的修订版的Git标签

本文发布于:2023-11-06 20:36:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564609.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:混帐   修订版   标签   svn   SVN

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!