diff options
-rwxr-xr-x | scripts/mandriva-svn2git.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/scripts/mandriva-svn2git.sh b/scripts/mandriva-svn2git.sh new file mode 100755 index 0000000..c50f17b --- /dev/null +++ b/scripts/mandriva-svn2git.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Reference: written following http://john.albin.net/git/convert-subversion-to-git + +SOFTWARE=$1 + +if [ -z $SOFTWARE ]; then + echo "Missing software to convert..." +fi + +if [ ! -f authors-transform.txt ]; then +# STEP 1: Create an author listi +echo 'OK' +svn log -q http://svn.mandriva.com/svn/soft | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2"@mandriva.org>"}' | sort -u >> authors-transform.txt +#vim authors-transform.txt +fi + +# STEP 2: Import in git +git svn clone http://svn.mandriva.com/svn/soft/$SOFTWARE --no-metadata -A authors-transform.txt --stdlayout temp + +# STEP 3: Convert svn:ignore properties to .git ignore +cd temp +git svn show-ignore > .gitignore +git add .gitignore +git commit -m 'Convert svn:ignore properties to .gitignore.' +cd .. + +# STEP 4: Create a bare repository +git init --bare new-bare.git +cd new-bare.git +git symbolic-ref HEAD refs/heads/trunk +cd .. + +cd temp +git remote add bare ../new-bare.git +git config remote.bare.push 'refs/remotes/*:refs/heads/*' +git push bare +cd .. + +# STEP 5: Rename trunk to master +cd new-bare.git +git branch -m trunk master +cd .. + +# STEP 6: Cleanup branches and tags +cd new-bare.git +git for-each-ref --format='%(refname)' refs/heads/tags | +cut -d / -f 4 | +while read ref +do + git tag "$ref" "refs/heads/tags/$ref"; + git branch -D "tags/$ref"; +done +cd .. + +mv new-bare.git $SOFTWARE.git + + +# CLEANUP +mv temp $SOFTWARE-origin + +exit 0 |