#!/bin/bash function runcommand { "$@" local status=$? if [ $status -ne 0 ]; then echo "error with $1" >&2 fi return $status } PROGRAMNAME=$(basename $0) if [ $# -ne 2 ] ; then echo "Usage $PROGRAMNAME " echo "$PROGRAMNAME creates a _svnbackup Dir" echo "and a _unversioned Dir" echo "then it clones your Github repository by 'clone https://github.com//.git'" echo "and finally copies all unversioned files from the old svn data into the new git directory" exit fi if [ -d $2_svnbackup ] ; then echo "$2_svnbackup does already exist !" echo "Did the program maybe run before? Please check before try $PROGRAMNAME again" exit fi if [ -d $2_unversioned ] ; then echo "$2_unversioned does already exist." echo "For security, this need to be removed manually before try $PROGRAMNAME again" exit fi echo "Create directory copies:" runcommand cp -r $2 $2_unversioned runcommand mv $2 $2_svnbackup echo "Clone repostitory:" runcommand git clone https://github.com/$1/$2.git echo "remove svn artifacts:" runcommand cd $2_unversioned runcommand svn list -R | xargs rm find . -name ".svn" -exec rm -rf {} \; 2>/dev/null runcommand cd .. echo "copy remaining unversioned files into new git repository:" runcommand cp -r $2_unversioned/* $2 echo "Check results between old svn directory and new git repository:" diff -r -q $2_svnbackup $2