Created
August 19, 2011 14:32
-
-
Save cebe/1156937 to your computer and use it in GitHub Desktop.
script to mirror svn repository
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
# subversion | |
.subversion | |
# mirror dirs | |
/mirror/* | |
/tmp/* |
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/sh | |
# | |
if [ "$1" = "" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then | |
echo "git > svn mirror script by CeBe <[email protected]>" | |
echo "" | |
echo "usage: $0 svnurl [giturl]" | |
echo "" | |
echo " svnurl base url to svn repo, NOT url to trunk! must end with /" | |
echo " giturl url of git repo to push code to. this repo should be empty" | |
echo " if not specified, you have to push repo in ./mirror yourself" | |
echo "" | |
echo "requires git, svn, php and svn2git (https://github.com/nirvdrum/svn2git)" | |
echo "" | |
exit 1; | |
fi | |
# create empty tmp dir | |
if [ -d ./tmp ] ; then | |
rm -rf ./tmp | |
fi | |
mkdir ./tmp | |
cd ./tmp | |
svn checkout $1 svn | |
# generate authors file | |
touch authors.txt | |
cd svn | |
php ../../authors.php > ../authors.txt | |
cd ../../ | |
mkdir mirror | |
cd mirror | |
svn2git $1 -m -v --authors ../tmp/authors.txt | |
if ! [ "$2" = "" ] ; then | |
git remote add gitmirror $2 | |
git push -u --all gitmirror | |
git push --tags gitmirror | |
fi | |
cd .. |
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/sh | |
# | |
cd mirror | |
svn2git --rebase | |
ret=$? | |
if [ $ret -eq 0 ] ; then | |
git push -u --all gitmirror | |
ret=$? | |
fi | |
if [ $ret -eq 0 ] ; then | |
git push --tags gitmirror | |
ret=$? | |
fi | |
cd .. | |
exit $ret |
make sure to have your git config set up correctly before running the script. It needs the user.name and user.email settings to be set.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using https://github.com/nirvdrum/svn2git to mirror yii repository here. You have to install it to use the scripts listed here...