Skip to content

Instantly share code, notes, and snippets.

@odd-poet odd-poet/svn2git.sh

Created Jul 22, 2012
Embed
What would you like to do?
조낸 심플한 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
You can’t perform that action at this time.