Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have a trailing space character in authors file for git svn

Tags:

git-svn

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?

like image 505
Ashfame Avatar asked Feb 24 '12 22:02

Ashfame


2 Answers

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
like image 180
CrazySquirrel Avatar answered Sep 27 '22 23:09

CrazySquirrel


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.

like image 40
Ashfame Avatar answered Sep 27 '22 23:09

Ashfame