开发的代码放在svn,但是svn推送分支的代价太高了,每个分支目录都是一次全拷贝,所以写了个脚本把svn分支转化为git分支,然后用git发布。
#!/bin/bash
name=$1
version=$2
svnurl=https://svnserver/svn/source/${name}/branches/${version}/
giturl=ssh://git@gitserver/group/${name}.git
gittmp=/data/git
mkdir -p ${gittmp}
svnsrc=/data/svntogit/${name}/${version}/
gitsrc=${gittmp}/${name}
if [ ! -d $svnsrc ];then
mkdir -p $svnsrc
cd $svnsrc
svn co $svnurl .
else
cd $svnsrc
svn co $svnurl .
fi
cd $gittmp
if [ ! -d ${gitsrc}/.git ];then
rm -rf ${gitsrc}
git clone $giturl
cd ${gitsrc}
git config --global core.autocrlf false
git config --global core.safecrlf false
git config core.autocrlf false
git config core.safecrlf false
else
cd ${name}
git pull
fi
cd /data/svntogit
cd $name
cd ${version}
rsync -a --delete ${svnsrc}/ --exclude=.git ${gitsrc}/
cd ${gitsrc}
git add --all .
git commit -a -m "new tag $version"
git push origin master
branch=$(git branch | grep b_${version})
if [ -n "$branch" ]; then
git branch -d b_${version}
fi
git checkout -b b_${version}
git push origin b_${version}
git checkout master
tag=$(git tag | grep t_${version})
if [ -n "$tag" ]; then
echo echo "exits"
else
git tag t_${version}
git push origin t_${version}
fi