<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>random utterings...: Subversion script for Rails developers</title>
    <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Subversion script for Rails developers</title>
      <description>&lt;p&gt;I read somewhere that good developers use version control.  There's a good article on &lt;a href="http://wiki.rubyonrails.org/rails/pages/HowtoUseRailsWithSubversion"&gt;HowtoUseRailsWithSubversion&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So why should I repeat those steps for every new project I work on.&lt;/p&gt;

&lt;p&gt;There is another &lt;a href="http://www.railsonwave.com/railsonwave/2006/12/19/smart-subversion-script-for-rails-projects"&gt;article&lt;/a&gt; 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.&lt;/p&gt;

&lt;p&gt;The following script takes it a bit farther.  You call it like this.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rails-svn app_dir repository username
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So if I wanted to create a new rails project called toejam, I would execute:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rails-svn toejam svn://randomutterings.com/projects/toejam/trunk chris
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here's what happens under the hood.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;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.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;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.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The original app directory is deleted and a working copy is checked out from the repository into that directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;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.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;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!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Subversion is told to ignore everything in the tmp folder, the .htaccess files, and the dispatch.fcgi file.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre&gt;
    #!/bin/bash

    if [ "$#" != "3" ]; then
      echo "Usage: rails-svn app_dir repository username"
      exit 1
    fi

    APPDIR=./$1
    SVN_TRUNK=$2
    SVN_USER=$3

    function check_if_exist () {
      if [[ -e $1 ]]; then
        echo ""
        echo "$1 already exists, overwrite? y or n"
        echo ""
        read OVERWRITE
        case "$OVERWRITE" in
        y)
          echo "Overwriting..."
          ;;
        *)
          echo "Action canceled"
          exit 1
          ;;
        esac
      fi
    }

    check_if_exist ${APPDIR}
    rails $APPDIR
    svn import $APPDIR $SVN_TRUNK -m "Import" --username $SVN_USER
    sudo rm -r $APPDIR
    svn checkout $SVN_TRUNK $APPDIR
    cd $APPDIR

    svn remove log/*
    svn commit -m "removing log files" 
    svn propset svn:ignore "*.log" log/
    svn update log/
    svn commit -m "Ignoring all files in /log/ ending in .log"
    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"
    svn remove tmp/*
    svn propset svn:ignore "*" tmp/
    svn update tmp/
    svn commit -m "ignore tmp/ content from now" 
    svn propset svn:ignore ".htaccess" public/
    svn update public/
    svn commit -m "Ignoring .htaccess"
    svn propset svn:ignore "dispatch.fcgi" public/
    svn update public/
    svn commit -m "Ignoring dispatch.fcgi"
&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;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 &lt;a href="mailto:randomutterings@gmail.com"&gt;email me&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Wed, 19 Sep 2007 15:15:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:39260e1f-ef69-495a-93fe-7ae6cfb13748</guid>
      <author>Chris Barnes</author>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers</link>
      <category>Ruby on Rails</category>
      <category>Subversion</category>
      <category>ruby</category>
      <category>rails</category>
      <category>Scripts</category>
      <category>bash</category>
      <trackback:ping>http://blog.randomutterings.com/articles/trackback/25</trackback:ping>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by acompanhantes</title>
      <description>

Thank you for the informative content.
&lt;a href="http://www.frentesquentes.com" rel="nofollow"&gt;http://www.frentesquentes.com&lt;/a&gt; acompanhantes
&lt;a href="http://www.frentesquentes.com" rel="nofollow"&gt;acompanhantes&lt;/a&gt;</description>
      <pubDate>Mon, 22 Aug 2011 17:45:45 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:8821910f-13e4-4cc5-9920-aed5b958ed1d</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6728</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by caneta espi&#227;</title>
      <description>What a nice article, thank you.
&lt;a href="http://74.53.157.210/" rel="nofollow"&gt;caneta espi&#227;&lt;/a&gt;</description>
      <pubDate>Thu, 18 Aug 2011 02:42:06 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:57a5213c-df64-4575-bf53-3c7424925a47</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6726</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by lussypointing@yahoo.com</title>
      <description>This blog is really informative.I have read this blog and this blog is very useful for me.I have waiting next article.Thanks for great information shearing.&lt;a href="http://www.PolicyInteractive.com" rel="nofollow"&gt;http://www.PolicyInteractive.com&lt;/a&gt;. </description>
      <pubDate>Wed, 08 Jun 2011 11:15:26 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:1a9cee96-3e2d-4a14-adff-227033333859</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6621</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by sam</title>
      <description>This articles helps me more.Thanks for your sharing,I will pay more attentions to your blog. Looking forward to your better and better articles.See you next time.
&lt;a href="http://www.tiffanysave.com" rel="nofollow"&gt;tiffany &amp; co &lt;/a&gt;</description>
      <pubDate>Thu, 03 Mar 2011 09:14:16 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:31ed890e-8740-4dab-8da5-63dfc4577434</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6363</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by chaussure basket</title>
      <description>Yeah! I very like this!@</description>
      <pubDate>Fri, 10 Dec 2010 03:56:29 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a7702f2d-1332-4fa4-82a2-d52b5ca67926</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6312</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by Beats Headphones</title>
      <description>bravo &#224; vous deux !!! pas mal votre id&#233;&#233; de faire sponsoris&#233; votre mariage !!jje vous souhaite tout le bonheur du monde !!! vous etiez magnifique !!! que de beaux souvenirs pour vous !!! soyez heureux 
bisous odile de marseille</description>
      <pubDate>Mon, 22 Nov 2010 07:22:40 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:f4146912-4e0a-4589-98dc-53e306a8f607</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6305</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by Beats Headphones</title>
      <description>Congrats to you guys for making the finest choice in the third party code you ship!</description>
      <pubDate>Sat, 20 Nov 2010 14:17:45 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a5fa31f3-55f0-4e34-a8be-96a87cb9a419</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6304</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by lista email</title>
      <description>Chris Barnes my friend, thanks for sharing this script.</description>
      <pubDate>Sun, 17 Oct 2010 21:45:36 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a862de86-18b7-41e6-a3ef-d34c8d8e3f81</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6289</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by hdfh</title>
      <description>pt directed to Rails developers? I am interested in the progress and transformation of any programming script.</description>
      <pubDate>Mon, 11 Oct 2010 08:55:11 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:7a53dbb0-9557-411a-9161-40c61cbd8f9e</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6286</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by Ann</title>
      <description>Thanks for information! </description>
      <pubDate>Wed, 08 Sep 2010 12:15:57 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:0edcf6b0-70ec-4a16-afd9-cdc569490f87</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-6240</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by Perry Cunningham</title>
      <description>Have you perfected this particular subversion script directed to Rails developers? I am interested in the progress and transformation of any programming script.&lt;br&gt;&lt;br&gt;

&lt;a href="http://www.turkeyneckcream.com" rel="nofollow"&gt;neck firming cream&lt;/a&gt;</description>
      <pubDate>Tue, 18 May 2010 13:58:17 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c2c08b99-270c-403f-aa04-fc62c4bbea00</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-5907</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by Frederick</title>
      <description>Hi have you been improving this code lately? I am curious as to whether some people left comments via email. I am interested if your code has indeed reached the gem stage.&lt;br&gt;&lt;br&gt;

&lt;a href="http://www.bdsmplaypen.com/video/gangbang_explosion_in_bondage-1294" rel="nofollow"&gt;Free Bondage Videos&lt;/a&gt;</description>
      <pubDate>Tue, 18 May 2010 12:14:14 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c6024533-7b14-4b56-9e14-cd2c65607881</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-5906</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by face blog</title>
      <description>Thank you. Your explanation is even clear than a tutorial. It is short and sweet....awesome post.</description>
      <pubDate>Sat, 27 Mar 2010 10:13:11 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:d8f637c3-503f-4bf5-b4e8-6cad68e585a6</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-5728</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by rssnewsdigest</title>
      <description>Try rssnewsdigest.com, a new comprehensive news aggregator. With rssnewsdigest, you don &#8217;t really have to go anywhere else.
	&lt;a href="http://rssnewsdigest.com" rel="nofollow"&gt;http://rssnewsdigest.com&lt;/a&gt;</description>
      <pubDate>Thu, 03 Apr 2008 07:36:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a04a41b9-d5ef-448f-9eb2-b8b7582d9fd8</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-1563</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by Chris Barnes</title>
      <description>You're right Matt, I changed those lines, they should have been applied to the public directory.</description>
      <pubDate>Wed, 07 Nov 2007 16:26:47 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5def115c-a4b0-4866-8cc7-f65b852a62fc</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-20</link>
    </item>
    <item>
      <title>"Subversion script for Rails developers" by matt</title>
      <description>I was poking around in my own script that I wrote and noticed two lines that I have and you have as well:

svn propset svn:ignore "dispatch.fcgi" config/
svn propset svn:ignore ".htaccess" config/

I deleted my cause I don't see how a htaccess or a dispatch file would find it's way into the config directory.  Is there something I'm forgetting here?</description>
      <pubDate>Fri, 26 Oct 2007 00:18:46 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:2f023bab-ddd9-4f84-ae09-591ed8aa9103</guid>
      <link>http://blog.randomutterings.com/articles/2007/09/19/subversion-script-for-rails-developers#comment-9</link>
    </item>
  </channel>
</rss>

