Version Control on Rails

In my consultancy assignments, I usually work in large organisations that have outsourced IT departments and very formal processes for everything. One aspect of this is version control.

In such an organisation every document contains a long table near the beginning with a row for every change, who made the change and when it was made and of course there will be a version number for every change. Usually the version number has at least 2 parts.

Also, the file name will have the version number in it, such as: “Some Formal Document v1.3a.doc”.

Traditionally (over the last 15 years or so) the files are stored in a Windows share. There will also be copies on local drives on various individuals’ PCs. How often do we find different people have different versions and they all believe them to be the latest?

Now, many organisations are waking up to the benefits of version control systems. However, they usually do two stupid things. The first is that they buy a version control system and the second is that they use their expensive version control system as if it were a Windows share.

You don’t need to buy a version control system. You almost certainly don’t need to buy a “Software Configuration Management” system, nor do you need to buy an “Application Lifecycle Management” system. The best version control systems are free and they are called Subversion and CVS. Using these tools is easy and simple. Discipline is necessary to get the best out of them, but you don’t need a massive amount of training. If you are really keen, you could read Pragmatic Version Control using Subversion. (You are really keen, aren’t you?)

While you’re reading the book you could minimise your chances of going off the rails by following the simple recommendations listed below:

  • Let the version control system do the work!
  • Remember that the version in the version control system is the master version; any file on your local disk is not the master until you check it in to the version control system.
  • Do not change the name of a file from one version to another; all versions of one file go in the same folder, under the same name (then you can see the change history).
  • If you do need to change the name of a file or folder, do it in the the version control system client, not on the working file on your local disk. (If you do it in the version control system it will change the working file for you and everything will stay in sync.)
  • Never, nevernever put a version number, or date, or time in a filename – this is a version control system, not a Windows share!
  • Check in atomic units – one component per file – do not check in zip files or tar files
  • The version control system version information is trusted over any version information recorded inside a file – so do not record it inside the file.

So what has this got to do with Rails? Well, there is the DRY principle, to start with:

Every piece of knowledge in the system should be expressed in just one place.

The version control system keeps a log of your versions, so don’t keep an incomplete and out-of-date one in the document – delete that big table from the front of your document – you really do not need it. And do not put the version number in the document or in the file name. This is just repeating yourself and if you do that you will end up with many conflicting versions of the truth.

Every time someone works with the wrong version of a document, they waste company resources. Don’t tolerate it.


This article was originally published on BIonRails, another Data Management & Warehousing website

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.