summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Lécureuil <neoclust@mageia.org>2013-04-15 15:24:07 +0100
committerColin Guthrie <colin@mageia.org>2013-04-15 15:24:07 +0100
commit8610a6645672e21e7c684f23a57b5f03727c5504 (patch)
treefa11e4c8cccc7106489126e5fefdb418a74da3d0
downloadsvn-git-migration-8610a6645672e21e7c684f23a57b5f03727c5504.tar
svn-git-migration-8610a6645672e21e7c684f23a57b5f03727c5504.tar.gz
svn-git-migration-8610a6645672e21e7c684f23a57b5f03727c5504.tar.bz2
svn-git-migration-8610a6645672e21e7c684f23a57b5f03727c5504.tar.xz
svn-git-migration-8610a6645672e21e7c684f23a57b5f03727c5504.zip
Initial script to import Mandriva SVN into a git repository.
-rwxr-xr-xscripts/mandriva-svn2git.sh61
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