Created
June 3, 2014 11:12
-
-
Save PandaEox/42a9f27bff9d0515b51c to your computer and use it in GitHub Desktop.
Rewrite SVN User to git user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
raw=`cat users.txt` | |
IFS=$'\n' | |
arr=($raw) | |
output="" | |
for i in "${arr[@]}" | |
do | |
IFS='=' read -a line <<< "$i" | |
svn_user=`echo "${line[0]}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'` | |
git_name=`echo "${line[1]}" | egrep -o '(\w.*)\s*<' | egrep -o '\w.*\w'` | |
git_mail=`echo "${line[1]}" | egrep -o '<(.+)>' | egrep -o '[^<>]+'` | |
echo "Processing $svn_user who is really name ($git_name) with mail ($git_mail)" | |
output=$( cat <<EOF | |
$output | |
if [ "\$GIT_COMMITTER_EMAIL" = "$svn_user" ] | |
then | |
cn="$git_name" | |
cm="$git_mail" | |
fi | |
if [ "\$GIT_AUTHOR_EMAIL" = "$svn_user" ] | |
then | |
an="$git_name" | |
am="$git_mail" | |
fi | |
EOF | |
) | |
done | |
git filter-branch -f --env-filter " | |
an=\"\$GIT_AUTHOR_NAME\" | |
am=\"\$GIT_AUTHOR_EMAIL\" | |
cn=\"\$GIT_COMMITTER_NAME\" | |
cm=\"\$GIT_COMMITTER_EMAIL\" | |
$output | |
export GIT_AUTHOR_NAME=\"\$an\" | |
export GIT_AUTHOR_EMAIL=\"\$am\" | |
export GIT_COMMITTER_NAME=\"\$cn\" | |
export GIT_COMMITTER_EMAIL=\"\$cm\" | |
" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DaPanda = Da Panda <[email protected]> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment