Skip to content

Instantly share code, notes, and snippets.

@MekDrop
Last active August 29, 2015 14:25
Show Gist options
  • Save MekDrop/d51413ba4fe799bf0b7b to your computer and use it in GitHub Desktop.
Save MekDrop/d51413ba4fe799bf0b7b to your computer and use it in GitHub Desktop.
Script to migrate from Assembla SVN one repo to multiple GitHub repos
#!/bin/bash
# ----------------------------------------
# If You want migrate one repo from Assembla SVN to multiple GitHub repos
# (different repo - different svn folder) this script can help You :)
#
# What You need to make this script workable:
# * Change variables below
# * Install svn2git from https://github.com/nirvdrum/svn2git
# * Make sure your git works with ssh keys
# ----------------------------------------
#Change these variables
USER=LOGIN:PASS
REPONAME=ENTER_HERE_REPOSITORY_NAME
AUTHORSFILE=authors.txt
CONTENTTYPE=module
CONTENTPREFIX=ENTER_PREFIX_HERE
SUBFOLDER=modules
ORGNAME=ENTER_YOUR_ORGANIZATION_NAME
# Do NOT change if are unsure what is Here
rm -rf result
mkdir result
svn co https://subversion.assembla.com/svn/$REPONAME
cd $REPONAME/$SUBFOLDER/
for dir in * ; do
if [ ! -d "$dir" ]; then
continue;
fi
trunk_path=trunk
tags_path=tags
branches_path=branches
if [ -d "$dir/releases" ]; then
tags_path=releases
fi
if [ -d "$dir/tasks" ]; then
branches_path=tasks
fi
cmd="svn2git --metadata --authors $AUTHORSFILE --no-minimize-url https://subversion.assembla.com/svn/$REPONAME/$SUBFOLDER/$dir"
if [ -d "$dir/$trunk_path" ]; then
if [ -d "$dir/$tags_path" ]; then
cmd="$cmd --tags $tags_path"
else
cmd="$cmd --notags"
fi;
if [ -d "$dir/$branches_path" ]; then
cmd="$cmd --branches $branches_path"
else
cmd="$cmd --nobranches"
fi;
else
cmd="$cmd --rootistrunk"
fi
cd ../../result/
mkdir $dir
cd $dir
pwd
$cmd
REPO=$CONTENTPREFIX-$CONTENTTYPE-$dir
curl -u "$USER" https://api.github.com/orgs/$ORGNAME/repos -d "{\"name\":\"$REPO\"}"
git remote add origin git@github.com:$ORGNAME/$REPO.git
git push origin master
git push --tags
git push --all
cd ..
cd ../$REPONAME/$SUBFOLDER/
done
cd ../..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment