Monday, February 18, 2008

Creating an SVN repositoy

I do a bunch of personal projects and, in the spirit of keeping it all under source control, I always create an SVN repository for all of them (even if I don’t finish them… after all, I suffer from NADD). Because I like to automate everything, here’s the script I use to startup projects:

#!/bin/sh
TMPDIR=/tmp/svntmpdir
REPODIR=/home/rsc/Documents/repositories
REPOURL=file://$REPODIR

if [ $1 == ""] ; then
    echo Usage: $0 {repository name}
    exit 1
fi

echo Creating directory structure
echo $TMPDIR
mkdir $TMPDIR
mkdir $TMPDIR/trunk
mkdir $TMPDIR/branches
mkdir $TMPDIR/tags
echo Creating repository $1
svnadmin create $REPODIR/$1
cd $TMPDIR
svn import $REPOURL/$1 -m "Initial structure"
echo Checking out
cd -
svn co $REPOURL/$1/trunk $1
echo Cleaning up
rm -Rf $TMPDIR
echo Done!

No comments: