从 SVN 转换为 Git 时,如何将修订号放入提交消息中?

发布于 2024-11-30 09:46:13 字数 320 浏览 1 评论 0原文

我们将把我们的存储库从 Subversion 转换为 Git,但希望能够保留 SVN 修订号,因为错误跟踪器中的注释会定期引用它。

我们将使用 git svn clone 以及 中描述的过程约翰·阿尔宾的博客

有没有办法在提交消息中包含修订号?我更愿意在克隆期间执行此操作,但后处理步骤也是可以接受的。

是的,我知道 git svn find-rev,但这需要 SVN 存储库保留并且用户具有对其的网络访问权限。

We will be converting our repository from Subversion to Git, but would like to be able to retain the SVN revision number as comments in the bug tracker regularly reference it.

We will be using git svn clone and the process described in John Albin's blog.

Is there a way to include the revision number in the commit message? I'd prefer to do it during the clone, but a post-processing step would be acceptable.

Yes, I know about git svn find-rev, but that requires the SVN repository stick around and the user has network access to it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你在我安 2024-12-07 09:46:13

git svn 默认情况下会执行此操作:它通常在每个提交消息中包含一行,其中包含该提交的 SVN 修订号(以及一些其他数据)。

但是,您发布的链接让您使用 --no-metadata 进行克隆,它告诉 git svn 不要附加 git-svn-id线。

git svn does this by default: it normally includes a line in every commit message that has the SVN revision number (and some other data) for that commit.

However, the link you posted has you cloning with --no-metadata, which tells git svn not to append the git-svn-id line.

始终不够 2024-12-07 09:46:13

目前尚不清楚为什么您希望在提交消息中包含 svn 修订号。正如 @John Flatness 所示,git-svn 在提交消息中包含 svn 修订号。

我们发现为每个修订创建标签更有用。这似乎更符合 svn 修订号的用处。使用 git svn find-rev 的脚本快速添加了 10000 个标签。现在我们可以访问任何历史 svn 修订号。


这里的每个请求都是脚本(在此处添加是因为注释似乎不能很好地处理代码)

#!/bin/bash

declare -i rev

for ((rev = 1; rev < 100; ++rev))
do
    hash=$(git svn find-rev "r$rev")
    if [ -z $hash ]; then
        break
    fi
    # TODO Pad with 0's for small values of rev
    tag="svn_r$rev"
    git tag -a -m "$tag" $tag $hash
done

这仅执行前 100 个修订。我们在前 5000 转时步进了 1000,然后步进了 100。最后 2000 次左右的提交有单独的标签。

It's not clear why you would want the svn revision number in the commit message. As @John Flatness indicates, the git-svn includes the svn revision number in the commit messages.

We found it more useful to create tags for each revision. This seems to better parallel the usefulness of the svn revision numbers. A script that uses git svn find-rev quickly added 10000 tags. Now we can access any historical svn revision number.


Per request here is the script (added here because comments don't seem to handle code well)

#!/bin/bash

declare -i rev

for ((rev = 1; rev < 100; ++rev))
do
    hash=$(git svn find-rev "r$rev")
    if [ -z $hash ]; then
        break
    fi
    # TODO Pad with 0's for small values of rev
    tag="svn_r$rev"
    git tag -a -m "$tag" $tag $hash
done

This just does the first 100 revisions. We stepped by by a 1000 for the first 5000 revs then by a 100. The last 2000 or so commits have individual tags.

等待我真够勒 2024-12-07 09:46:13

这个脚本对于使用 svn 的部分分支的人来说效果更好。
因为当没有修订返回时,中断就会消失。试试这个。
只需将 50000 设置为每个最大修订版本号即可。

declare -i rev

for rev in {1..50000}
do
    echo $rev
    hash=$(git svn find-rev "r$rev")
    tag="svn_r$rev"
    if [ -z $hash ] 
    then
        echo no tag
    else
        echo $hash
        echo $tag
        git tag -a -m "$tag" $tag $hash
    fi
done

echo Thats it !

This script works better for people taking partial branches of svn.
Because the break drops out when no revision returned. Try this one.
Just need to make the 50000 what every your max revision number is.

declare -i rev

for rev in {1..50000}
do
    echo $rev
    hash=$(git svn find-rev "r$rev")
    tag="svn_r$rev"
    if [ -z $hash ] 
    then
        echo no tag
    else
        echo $hash
        echo $tag
        git tag -a -m "$tag" $tag $hash
    fi
done

echo Thats it !
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文