-
-
Save nathandaly/3253f69060bea81ca83366f68741b65d 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment