Created
July 22, 2012 06:27
-
-
Save odd-poet/3158671 to your computer and use it in GitHub Desktop.
조낸 심플한 svn2git script.
This file contains 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 | |
# simple svn2git script. | |
# author : yunsang.choi ([email protected]) | |
# | |
# It checkouts svn repository to local git repository | |
# include branches and tags. | |
#===================================== | |
svn2git() { | |
local url=$1 | |
local project_name=`echo "$url" | grep -o -E "([^/]*?)\/?$" | grep -o -E "[^/]*"` | |
echo "SVN to Git : $url" | |
echo "-------------------" | |
git svn clone $url -s | |
if [ $? -gt 0 ];then | |
echo "FAIL to checkout!" | |
return | |
fi | |
cd $project_name | |
branches=($(git branch -r)) | |
for branch in ${branches[@]};do | |
echo " > checkout branch : $branch" | |
git checkout -b $branch remotes/$branch | |
done | |
cd .. | |
echo | |
} | |
input=$1 | |
if [[ $input = *http://* ]];then | |
# url input | |
svn2git $input | |
elif [[ -f $input ]];then | |
urls=( $( < $input )) | |
for url in ${urls[@]}; do | |
svn2git $url | |
done | |
else | |
me=`basename $0` | |
echo -e "usage: " | |
echo -e " \x1b[1m$me url\x1b[22m # svn repo url " | |
echo -e " \x1b[1m$me file\x1b[22m # file that contains svn urls " | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment