git, submodules and Capistrano

Posted on Sun Feb 17 21:47:00 UTC 2008

If you use git submodules, as git-rails does, and want to use Capistano, you’ll need to patch patch Capistrano (lib/capistano/recipes/deploy/scm/git.rb) to make sure your submodules get included.

        def checkout(revision, destination)
          git      = command

          branch   = head

          fail "No branch specified, use for example 'set :branch, \"origin/master\"' in your deploy.rb" unless branch

          if depth = configuration[:git_shallow_clone]
            execute  = "#{git} clone --depth #{depth} #{configuration[:repository]} #{destination} && " 
          else
            execute  = "#{git} clone #{configuration[:repository]} #{destination} && " 
          end

          execute += "cd #{destination} && #{git} checkout -b deploy #{branch}" 

          if submodules = configuration[:git_enable_submodules]
            execute += " && git-submodule init &&" 
            execute += "git-submodule update" 
          end

          execute
        end
then define this in your deploy.rb:
set :git_enable_submodules,1

Or you can use the trunk version (post 2.1), which includes that support already.

Posted in Rails  |  Tags ,  |  1 comment

Comments

  1. Alicia Alicia said // Feb 18, 2008 at 05:24 AM

    I used this with Capistrano, i was very successful! I made the codes from scratch and it worked perfectly.