Using Bundler with Subversion

Yes, git is the coolest version control system (VCS), but sometimes you get stuck having to use another VCS.  Been there, done that, here’s a quick how to on using bundler with subversion.

This example uses Bundler version 1.1.5 and svn version 1.6.18.

First we create a gem project using bundler and rvm.

➤ bundle gem svn-bundler-demo
create  svn-bundler-demo/Gemfile
create  svn-bundler-demo/Rakefile
create  svn-bundler-demo/LICENSE
create  svn-bundler-demo/
create  svn-bundler-demo/.gitignore
create  svn-bundler-demo/svn-bundler-demo.gemspec
create  svn-bundler-demo/lib/svn-bundler-demo.rb
create  svn-bundler-demo/lib/svn-bundler-demo/version.rb
Initializating git repo in /Users/roy/Projects/svnroot/svn-bundler-demo
➤ cd svn-bundler-demo
➤ rvm use --rvmrc --create 1.9.3@svn-bundler-demo
Using /Users/roy/.rvm/gems/ruby-1.9.3-p286 with gemset svn-bundler-demo
➤ git ls-files

Next we convert the project to use subversion instead of git:

➤ rm -rf .git
➤ cd ..
➤ svn add svn-bundler-demo
A         svn-bundler-demo
A         svn-bundler-demo/.gitignore
A         svn-bundler-demo/.rvmrc
A         svn-bundler-demo/Gemfile
A         svn-bundler-demo/lib
A         svn-bundler-demo/lib/svn-bundler-demo
A         svn-bundler-demo/lib/svn-bundler-demo/version.rb
A         svn-bundler-demo/lib/svn-bundler-demo.rb
A         svn-bundler-demo/LICENSE
A         svn-bundler-demo/Rakefile
A         svn-bundler-demo/
A         svn-bundler-demo/svn-bundler-demo.gemspec
➤ svn commit -m 'initial gem'
Adding         svn-bundler-demo
Adding         svn-bundler-demo/.gitignore
Adding         svn-bundler-demo/.rvmrc
Adding         svn-bundler-demo/Gemfile
Adding         svn-bundler-demo/LICENSE
Adding         svn-bundler-demo/
Adding         svn-bundler-demo/Rakefile
Adding         svn-bundler-demo/lib
Adding         svn-bundler-demo/lib/svn-bundler-demo
Adding         svn-bundler-demo/lib/svn-bundler-demo/version.rb
Adding         svn-bundler-demo/lib/svn-bundler-demo.rb
Adding         svn-bundler-demo/svn-bundler-demo.gemspec
Transmitting file data .........
Committed revision 6.
➤ svn update
At revision 6.
➤ cd svn-bundler-demo
= NOTICE                                                                           =
= RVM has encountered a new or modified .rvmrc file in the current directory       =
= This is a shell script and therefore may contain any shell commands.             =
=                                                                                  =
= Examine the contents of this file carefully to be sure the contents are          =
= safe before trusting it! ( Choose v[iew] below to view the contents )            =
Do you wish to trust this .rvmrc file? (/Users/roy/Projects/svnroot/svn-bundler-demo/.rvmrc)
y[es], n[o], v[iew], c[ancel]> y
Using: /Users/roy/.rvm/gems/ruby-1.9.3-p286@svn-bundler-demo
➤ svn ls -R

Notice the differences between the “git ls-files” and “svn ls -R”.  The git ls-files shows just the files while the svn ls shows directories and files.

And now the trick.  Edit the gemspec file (svn-bundler-demo.gemspec) and locate the following line:

gem.files         = `git ls-files`.split($\)

replace with:

gem.files         = `svn ls -R`.split($\).reject{|fn| fn =~ /\/$/}

Note that bundler requires a .gitignore file so you will need to keep it.

Have fun!