如何在 git svn 的作者文件中包含尾随空格字符

发布于 2025-01-08 20:29:13 字数 2014 浏览 1 评论 0原文

我的 svn 仓库中的作者如下:

$ svn 日志 --xml | grep 作者 |排序 -u | perl -pe 's/.>(.?)<./$1 = /'

输出:

<author>ashfame</author>
<author>clean</author>
<author>clean </author>
<author>rocketweb</author>

但是在使用 git svn clone 克隆存储库以进行导入时,它会在说 之间停止作者:clean 未在 /home/ashfame/fun/authors-transform.txt 文件中定义

请注意 clean 后面的双空格,这意味着它是第三个用户“clean”

如何格式化我的作者文件以在用户名中包含空格?我当前的内容如下:

ashfame = Ashfame <[email protected]>
clean = Yogesh Tiwari <[email protected]>
clean = Yogesh Tiwari <[email protected]>
"clean\ " = Yogesh Tiwari <[email protected]>
"clean " = Yogesh Tiwari <[email protected]>
rocketweb = rocketweb <[email protected]>
(no author) = Yogesh Tiwari <[email protected]>
(no author) = no_author

有趣的发现:我尝试将 svn 存储库导入到 git 中,而无需任何用户映射我看不到任何与“clean”用户相关的内容,只有“clean”存在,所以我猜测这是 svn repo 上的一些问题。关于可以采取什么措施的任何指示?

Authors in my svn repo are as follows:

$ svn log --xml | grep author | sort -u | perl -pe 's/.>(.?)<./$1 = /'

Output:

<author>ashfame</author>
<author>clean</author>
<author>clean </author>
<author>rocketweb</author>

But while cloning the repo for import using git svn clone, it halts in between saying Author: clean not defined in /home/ashfame/fun/authors-transform.txt file

Notice the double space after clean, which means its the 3rd user "clean ".

How do I format my authors file to have a space in username? My current contents are as follows:

ashfame = Ashfame <[email protected]>
clean = Yogesh Tiwari <[email protected]>
clean = Yogesh Tiwari <[email protected]>
"clean\ " = Yogesh Tiwari <[email protected]>
"clean " = Yogesh Tiwari <[email protected]>
rocketweb = rocketweb <[email protected]>
(no author) = Yogesh Tiwari <[email protected]>
(no author) = no_author

Interesting discovery: I tried importing the svn repo into git without any user mapping and I couldn't see anything related to "clean " user, only "clean" exists, so I am guessing this is some hiccup on svn repo. Any pointers on what can be done about it?

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

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

发布评论

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

评论(3

习ぎ惯性依靠 2025-01-15 20:29:13

作者名中的空格也有类似的问题。

使用author-prog选项解决这个问题,该选项允许您使用bash脚本,这将转换未知的作者。

#!/bin/bash

if [ "$1" = "VisualSVN Server" ];then
    echo "VirtualSVNServer <svn.localdomain>";
fi

Had the similar problem with space in authorname.

Solve it using author-prog option, which allows you to use bash script, which will transform unknown authors.

#!/bin/bash

if [ "$1" = "VisualSVN Server" ];then
    echo "VirtualSVNServer <svn.localdomain>";
fi
悟红尘 2025-01-15 20:29:13

我不明白 SVN 存储库出了什么问题,所以我只是导入了它们,没有任何作者文件。然后我使用 Github 中的脚本重命名提交作者数​​据:

#!/bin/sh

git filter-branch --env-filter '

an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"

if [ "$GIT_COMMITTER_EMAIL" = "[email protected]" ]
then
    cn="Your New Committer Name"
    cm="Your New Committer Email"
fi
if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ]
then
    an="Your New Author Name"
    am="Your New Author Email"
fi

export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'

保存上面的代码在一个名为 change-commit-author-script.sh 的文件中,并将该文件放入您的存储库根目录中。通过 chmod +x change-commit-author-script.sh 使其可执行,然后通过 ./change-commit-author-script.sh 运行 是的

,不要'不要忘记编辑脚本来填写您的姓名和电子邮件值。

I couldn't figure what the hiccup was with the SVN repo, so I just imported them without any author file. And then I renamed the commit author data using this script from Github:

#!/bin/sh

git filter-branch --env-filter '

an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"

if [ "$GIT_COMMITTER_EMAIL" = "[email protected]" ]
then
    cn="Your New Committer Name"
    cm="Your New Committer Email"
fi
if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ]
then
    an="Your New Author Name"
    am="Your New Author Email"
fi

export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'

Save the above code in a file with a name say change-commit-author-script.sh and put the file in your repo root. Make it executable by chmod +x change-commit-author-script.sh and then run in by ./change-commit-author-script.sh

And yeah don't forget to edit the script to fill in your name and email values.

ゃ人海孤独症 2025-01-15 20:29:13

如果像我一样,您已经创建了一个 users.txt 并希望将其作为 --authors-file 传递,然后才意识到它不起作用,那么这里是一个利用现有 users.txt 并允许进行其他自定义的脚本:

#!/bin/sh

if [ -z ${GIT_SVN_USERS_TXT+x} ]; then
    echo "the environment variable GIT_SVN_USERS_TXT must be set to the path of your users.txt" >&2
    exit 1
fi

while read line; do
    # remove largest suffix and trim whitespace
    svn=$(echo ${line%%=*} | xargs)
    # remove smallest prefix and trim whitespace
    git=$(echo ${line#*=} | xargs)
    if [ "$1" = "$svn" ]; then
        echo "$git"
        exit 0
    fi
done < "$GIT_SVN_USERS_TXT"

if [ "$1" = "spaceatend " ]; then
    echo "VirtualSVNServer <svn.localdomain>"
    exit 0
fi

echo "Unable to find user $1" >&2
exit 1

像这样运行它:

GIT_SVN_USERS_TXT=/path/to/users.txt git svn clone --authors-prog=/path/to/script.sh --no-metadata ...

If, like me, you already created a users.txt that you wanted to pass as --authors-file only to then realize that it doesn't work, here is a script that makes use of your existing users.txt and allows one to make additional customizations:

#!/bin/sh

if [ -z ${GIT_SVN_USERS_TXT+x} ]; then
    echo "the environment variable GIT_SVN_USERS_TXT must be set to the path of your users.txt" >&2
    exit 1
fi

while read line; do
    # remove largest suffix and trim whitespace
    svn=$(echo ${line%%=*} | xargs)
    # remove smallest prefix and trim whitespace
    git=$(echo ${line#*=} | xargs)
    if [ "$1" = "$svn" ]; then
        echo "$git"
        exit 0
    fi
done < "$GIT_SVN_USERS_TXT"

if [ "$1" = "spaceatend " ]; then
    echo "VirtualSVNServer <svn.localdomain>"
    exit 0
fi

echo "Unable to find user $1" >&2
exit 1

Run it like this:

GIT_SVN_USERS_TXT=/path/to/users.txt git svn clone --authors-prog=/path/to/script.sh --no-metadata ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文