Sha256: 04802cf6f08177de7b6347723c17e3f0e9d010c5a76fd2ab8f2632b39ca3710b

Contents?: true

Size: 1.97 KB

Versions: 6

Compression:

Stored size: 1.97 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 repository root matches this deploy, then updating it"
            command = "if [ -d #{repository_cache} ] && ! echo '#{configuration[:repository]}' | grep -q `svn info #{repository_cache} | grep 'Repository Root' | awk '{print $3}'`; 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

6 entries across 6 versions & 1 rubygems

Version Path
engineyard-eycap-0.3.10 lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb
engineyard-eycap-0.3.6.1 lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb
engineyard-eycap-0.3.6 lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb
engineyard-eycap-0.3.7 lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb
engineyard-eycap-0.3.8 lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb
engineyard-eycap-0.3.9 lib/capistrano/recipes/deploy/strategy/filtered_remote_cache.rb