Created
January 24, 2013 15:23
-
-
Save loftux/4622983 to your computer and use it in GitHub Desktop.
Script to convert a specific subversion path to git, ignoring other subversion paths and content.
Not tested to handle merges, does not record commits with proper dates (historic dates in commit message). If you want all that there are better tools available.
This file contains hidden or 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/bash | |
# Convert a subversion repository path to git | |
# Author: Peter Löfgren, Loftux AB | |
# The subversion path to export | |
URL="https://share-extras.googlecode.com/svn/trunk/Media Preview" | |
# First revision this path exists | |
STARTREV=2 | |
svn co -r ${STARTREV} "${URL}" export | |
cd "$( dirname "$0" )/export" | |
if [ ! -f ".gitignore" ]; then | |
echo .svn >> .gitignore | |
fi | |
if [ ! -d ".git" ]; then | |
git init | |
git add . | |
git commit -m "Initial commit, export from ${URL}" | |
fi | |
localrev=$(( `svn info | grep Revision | awk '{print $2}'`+1 )) | |
remoterev=$((`svn info $( svn info | grep 'Root:' | awk -F': ' '{print $2}' ) | grep Revision | awk '{print $2}'`+1)) | |
echo Updating from $localrev to $remoterev | |
while [ $localrev -lt $remoterev ]; do | |
echo `date "+%Y-%m-%d %H:%M"` Updating $localrev | |
svn update -q -r $localrev | |
loggmessage=`svn log -r $localrev` | |
git add . | |
git ls-files --deleted | xargs git rm | |
git commit -m "${loggmessage:73}" | |
let localrev=localrev+1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment