Sha256: 8db6d698b613fd82119baee56c6a4f8fa9c1796001cafa2b9007a4cbfa4ea9a3

Contents?: true

Size: 1.38 KB

Versions: 5

Compression:

Stored size: 1.38 KB

Contents

require 'capistrano/bundle_rsync/scm'
require 'capistrano/configuration/filter'

class Capistrano::BundleRsync::LocalGit < Capistrano::BundleRsync::SCM
  def check
    raise ArgumentError.new('`repo_url` must be local path to use `local_git` scm') unless local_path?(repo_url)
    exit 1 unless execute("git ls-remote #{repo_url} HEAD")
    execute("mkdir -p #{config.local_base_path}")
  end

  def clone
  end

  def update
  end

  def create_release
  end

  def clean_release
  end

  def rsync_release
    hosts = ::Capistrano::Configuration.env.filter(release_roles(:all))
    rsync_options = config.rsync_options
    Parallel.each(hosts, in_threads: config.max_parallels(hosts)) do |host|
      ssh = config.build_ssh_command(host)
      if tree = fetch(:repo_tree)
        execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{repo_url}/#{tree}/ #{host}:#{release_path}/"
      else
        execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{repo_url}/ #{host}:#{release_path}/"
      end
    end
  end

  def set_current_revision
    within repo_url do
      set :current_revision, capture(:git, "rev-parse --short HEAD")
    end
  end

  private

  def local_path?(repo_url)
    return !(
      repo_url.start_with?('http://') or
      repo_url.start_with?('https://') or
      repo_url.start_with?('git://') or
      repo_url.start_with?('git@') or
      repo_url.start_with?('ssh://')
    )
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
capistrano-bundle_rsync-0.5.2 lib/capistrano/bundle_rsync/local_git.rb
capistrano-bundle_rsync-0.5.1 lib/capistrano/bundle_rsync/local_git.rb
capistrano-bundle_rsync-0.5.0 lib/capistrano/bundle_rsync/local_git.rb
capistrano-bundle_rsync-0.4.9 lib/capistrano/bundle_rsync/local_git.rb
capistrano-bundle_rsync-0.4.8 lib/capistrano/bundle_rsync/local_git.rb