freezing git Rails into your SVN project

While all the cool kids are switching to git (notably Rails itself), we still have several projects that live in svn repositories and we really have no desire to migrate them. We do, however, want to upgrade to the latest Rails version, now managed via git at github.com.

While I have found lots of old tutorials based on svn, or new ones explaining how to freeze rails to your git-based project, I have not seen a good one about freezing git-based rails to an svn-based project. Here are the steps I used:

First, remove your older svn-frozen copy of Rails
$ svn rm vendor/rails
$ svn ci -m 'upgrading rails to the latest git stable version *** this revision is missing rails ***'
Next, get your own local Rails repository
$ cd vendor
$ git clone git://github.com/rails/rails.git
$ cd rails
Now you can add the new version of Rails to your svn project
$ git checkout -b v2.1.1
$ svn add ../rails
$ svn revert --recursive .git
$ cd ../.. # back to your root dir
$ rake rails:update # update the supplemental rails files
$ svn ci -m 'upgrade to rails 2.1.1'

Of course, you can replace 2.1.1 with whatever the current version you are interested in. Later on, when a new version of Rails is released, you can simply update your git repo and switch to a new branch like so:

$ cd vendor/rails
$ git pull origin master
$ git checkout -b v2.2.0
$ svn status
# here you would have to add any deleted files, and add any new files
# this step could easily be automated
$ svn ci -m 'enjoy the latest Rails'

Note: If you are upgrading from 1.2.x -> 2.x.x make sure to add back the plugins that you were using such as will_paginate or acts_as_tree.

$ script/plugin install git://github.com/rails/acts_as_tree.git
$ svn add vendor/plugins/acts_as_tree
$ script/plugin install git://github.com/mislav/will_paginate
$ svn add vendor/plugins/will_paginate

Hope this helps anyone else trying to do the same thing. I am sure there are other ways to accomplish a this task as well. Feel free to put your solution in the comments.

Posted by Adeh Fri, 19 Sep 2008 16:51:00 GMT


Comments

  1. Frédéric de Villamil 27 days later:
    Thank you for this tutorial. Too bad I can't add a git project like rails as a svn:externals, it would be much easier... Hope you enjoy this wonderful blogging engine you're using
  2. adeh 27 days later:
    Hello Frédéric, we are enjoying it very much :) ! Glad to help.