Sha256: 9f02c98277f1230bf9f0b3eb954d7925360e9f51cbb3af99b15e0d40181f3342

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

require 'capistrano/recipes/deploy/strategy/remote'

module Capistrano
  module Deploy
    module Strategy

      # Implements the deployment strategy that keeps a cached checkout of
      # the source code on each remote server. Each deploy simply updates the
      # cached checkout, and then filters a copy through tar to remove unwanted .svn directories,
      # finally leaving a pristeen, export-like copy at the destination.
      class FilteredRemoteCache < Remote
        # Executes the SCM command for this strategy and writes the REVISION
        # mark file to each host.
        def deploy!
          update_repository_cache
          tar_copy_repository_cache
        end

        def check!
          super.check do |d|
            d.remote.writable(shared_path)
          end
        end

        private

          def repository_cache
            configuration[:repository_cache] || "/var/cache/engineyard/#{configuration[:application]}"
          end

          def update_repository_cache
            logger.trace "checking if the cached copy URL matches this deploy, then updating it"
            command = "if [ -d #{repository_cache} ] && ! [ `svn info #{repository_cache} | grep URL | awk '{print $2}'` = '#{configuration[:repository]}'  ]; then " + 
              "rm -rf #{repository_cache} && #{source.checkout(revision, repository_cache)}; " + 
              "elif [ -d #{repository_cache} ]; then #{source.sync(revision, repository_cache)}; " +
              "else #{source.checkout(revision, repository_cache)}; fi"
            scm_run(command)
          end

          def tar_copy_repository_cache
            logger.trace "copying and filtering .svn via tar from cached version to #{configuration[:release_path]}"
            run "mkdir #{configuration[:release_path]} && tar c --exclude=#{configuration[:filter_spec] || ".svn"} -C #{repository_cache} . | tar xC #{configuration[:release_path]} && #{mark}"
          end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
engineyard-eycap-0.3.3 lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb
engineyard-eycap-0.3.4 lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb