Posts Tagged ‘subversion’

Create a subversion repository for rails

First you need a directory to house your repository. Since I work on multiple projects at home and in the office I need a master directory first. And just to make it simple I use /repos. This could be a link or a real directory.
(To clean-out a old svn directory use the following find . -name .svn -exec ‘rm -rf {}\;‘)
Step 1:
# create /repos
Step 2 (Create a repository):
# svnadmin create /repos/rails_project
Step 3 (Create rails specific directories):
# export REPOS=file:///repos/rails_project
# svn mkdir –message=”Initial project layout” $REPOS/trunk $REPOS/tags $REPOS/branches
Step 4 (Initial Import of project):
# cd /rails_project
# svn import . file:///repos/rails_project/trunk -m “Initial Import…” */ This command import everything from the current directory to the svn server running locally using the file:/// structure */
Step 5 (check-out):
# svn co file:///repos/rails_project/trunk rails_project
# svn co svn://subversion_server/rails_project/trunk rails_project
Both of the above command will checkout the trunk of rails_project into a directory called rails_project.
Step 6 (Rails clean-up):
Go into the newly checked-out rails project
*/ Remove and Ignore the log files */  
# svn remove log/* 
# svn commit -m ‘removing all log files from subversion’ 
# svn propset svn:ignore “*.log” log/ 
# svn update log/ 
# svn commit -m ‘Ignoring all files in /log/ ending in .log */ Remove and Ignore tmp directory */   
# svn remove tmp/* 
# svn commit -m ‘removing all tmp artifacts from subversion’ 
# svn propset svn:ignore “*” tmp/ 
# svn update tmp/ 
# svn commit -m “ignore tmp/ content from now on” */ Move the database config file to an example file and ignore */   
# svn move config/database.yml config/database.example 
# svn commit -m “Moving database.yml to database.example to provide a template for anyone who checks out the code” 
# svn propset svn:ignore “database.yml” config/ 
# svn update config/ 
# svn commit -m “Ignoring database.yml”

Deploying with Subversion tags in Capistrano

This is a 0.1 deploy method 🙂 I have tested this and we are using this version in production BUT its is not stupid proof…
In the ./config/deploy.rb
# Setup the repository with the TAG variable ()
tag = (ENV[”TAG”] || “”)
set :repository, “http://svn.mypostit.local/#{application}/tags/#{tag}”
set :repository, “http://svn.mypostit.local/#{application}/trunk” if tag.empty?
Now you can deploy with:
[deployer@heimdull ]# cap deploy TAG=’my_tag’
Wow is that easy.. If the TAG environment variable is empty then it will use the trunk for the repository or else it will use whatever you put in TAG.
I guess I should check if the tag exists before continuing … maybe 0.2 🙂