Created
November 12, 2012 23:04
-
-
Save miohtama/4062655 to your computer and use it in GitHub Desktop.
Migrate several SVN projects to Github using a shell script
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/zsh | |
# | |
# Install svn2git https://github.com/nirvdrum/svn2git | |
# Install curl: sudo apt-get install curl | |
# | |
# Create API token Github on command line before running this script | |
# | |
# curl -u 'miohtama' -d '{"scopes":["repo"],"note":"migrate.sh"}' https://api.github.com/authorizations | |
# | |
# More info https://help.github.com/articles/creating-an-oauth-token-for-command-line-use | |
# | |
# Set Github API token externally before running this script | |
# | |
# TOKEN=yourgithubtokengoeshere ./migrate.sh | |
# | |
# SVN projects to migrate | |
projects=("gomobile.buildout" "gomobile.convergence" "gomobile.docs" "gomobile.imageinfo" "gomobile.mobile" "gomobile.supporter" "gomobile.templates" "gomobiletheme.basic" "gomobiletheme.mobipublic" "mfabrik.webandmobile" "mobile.heurestics" "mobile.htmlprocessing" "mobile.sniffer" "mobipublic.content" "plonecommunity.app") | |
# Where all SVN projects are | |
svnbase=http://plonegomobile.googlecode.com/svn/ | |
# Under which organization new projects are created on Github | |
org="plone-gomobile" | |
Migrate to git | |
for p in $projects; do | |
mkdir $p | |
cd $p | |
# Convert Google code SVN to Git repo | |
svn2git $svnbase/$p | |
cd .. | |
done | |
# Create Github projects, push to upstream | |
for p in $projects; do | |
# http://developer.github.com/v3/repos/#create | |
# http://stackoverflow.com/questions/7870680/github-v3-api-create-a-repo | |
# Test drive on a single liner | |
# TOKEN="xxxx" org="plone-gomobile" p=test ; curl -v -XPOST -H "Authorization: token $TOKEN" https://api.github.com/orgs/$org/repos -d '{"name": "'"$p"'"}' | |
curl -v -XPOST -H "Authorization: token $TOKEN" https://api.github.com/orgs/$org/repos -d '{"name": "'"$p"'"}' | |
cd $p | |
git remote add origin [email protected]:$org/$p.git | |
git push origin master | |
cd .. | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment