我的svn回购中的作者如下:
$ svn log --xml | grep作者| sort -u | perl -pe的/.>(。?)< ./$ 1 = /'
输出:
<author>ashfame</author>
<author>clean</author>
<author>clean </author>
<author>rocketweb</author>
但是在使用git svn clone
克隆导言以进行导入时,它会在Author: clean not defined in /home/ashfame/fun/authors-transform.txt file
请注意clean之后的双倍空格,这意味着它是第三个用户"clean "
。
如何格式化我的作者文件以在用户名中留出空格?我目前的内容如下:
ashfame = Ashfame <mail@example.com>
clean = Yogesh Tiwari <yogesh.tiwari@example.com>
clean = Yogesh Tiwari <yogesh.tiwari@example.com>
"clean\ " = Yogesh Tiwari <yogesh.tiwari@example.com>
"clean " = Yogesh Tiwari <yogesh.tiwari@example.com>
rocketweb = rocketweb <rocketweb@rocketweb.com>
(no author) = Yogesh Tiwari <yogesh.tiwari@example.com>
(no author) = no_author
有趣的发现:我尝试将svn repo导入git而没有任何用户映射,我看不到任何与“干净”用户相关的内容,只有“干净”存在,所以我猜这个在svn repo上有些打嗝。关于可以做些什么的任何指示?
答案 0 :(得分:4)
在authorname中有类似的空间问题。
使用author-prog选项解决它,它允许你使用bash脚本,它将改变未知的作者。
#!/bin/bash
if [ "$1" = "VisualSVN Server" ];then
echo "VirtualSVNServer <svn.localdomain>";
fi
答案 1 :(得分:2)
我无法确定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" = "your@email.to.match" ]
then
cn="Your New Committer Name"
cm="Your New Committer Email"
fi
if [ "$GIT_AUTHOR_EMAIL" = "your@email.to.match" ]
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
的文件中,并将该文件放入repo根目录中。使其chmod +x change-commit-author-script.sh
可执行,然后由./change-commit-author-script.sh
是的,不要忘记编辑脚本以填写您的姓名和电子邮件值。
答案 2 :(得分:0)
如果像我一样,你已经创建了一个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 ...