I read somewhere that good developers use version control. There’s a good article on HowtoUseRailsWithSubversion.
So why should I repeat those steps for every new project I work on.
There is another article which attempted to tackle this problem. However, you still have to do the initial steps and then copy this script into your project directory and execute it.
The following script takes it a bit farther. You call it like this.
rails-svn app_dir repository username
So if I wanted to create a new rails project called toejam, I would execute:
rails-svn toejam svn://randomutterings.com/projects/toejam/trunk chris
Here’s what happens under the hood.
After checking to make sure the directory doesn’t already exist, your rails app is created with the standard rails command. (If the directory already exists, you will be asked if you want to continue. Choosing yes will allow the script to continue but if this script has been run on the same app twice, all of the svn commits will be duplicated.)
Your new app is imported to the subversion repository specified. Authentication is done with the username provided. You may be prompted for a password from your repository.
The original app directory is deleted and a working copy is checked out from the repository into that directory.
All the default rails log files are removed and subversion is instructed to ignore those files. (Log files can get large and we definitely don’t need them in version control.)
The database.yml is moved to database.example to serve as a template for anyone who checks out the code and any newly created database.yml files are ignored by subversion. (Doing this will help if you have multiple developers working on the same project in different environments. It also prevents you from overwriting the database.yml file on the production server, oops!
Subversion is told to ignore everything in the tmp folder, the .htaccess files, and the dispatch.fcgi file.
Without further ado, here’s the script. Just copy it and save it somewhere in your path. /usr/bin is a good choice. Don’t forget to chmod 755 so you can execute it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
I’m interested in converting this into a gem and possibly rewriting it in ruby. If anyone has the skills and wants to contribute, leave a comment or email me.