Skip to content

Instantly share code, notes, and snippets.

@odd-poet
Created July 22, 2012 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odd-poet/3158671 to your computer and use it in GitHub Desktop.
Save odd-poet/3158671 to your computer and use it in GitHub Desktop.
조낸 심플한 svn2git script.
#!/bin/bash
# simple svn2git script.
# author : yunsang.choi (oddpoet@gmail.com)
#
# 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