Sha256: bd5239a2db5af95fa72bb3f8f8a9c81d0c9f6e82d1bfb8f9ff59573a12f8e701

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'capistrano/bundle_rsync/scm'

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}")
    execute("mkdir -p #{config.local_base_path}")
  end

  def clone
  end

  def update
  end

  def create_release
    hosts = release_roles(:all)
    rsync_options = config.rsync_options
    Parallel.each(hosts, in_processes: config.max_parallels(hosts)) do |host|
      ssh = config.build_ssh_command(host)
      execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{repo_url}/ #{host}:#{release_path}/"
    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

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-bundle_rsync-0.2.1 lib/capistrano/bundle_rsync/local_git.rb
capistrano-bundle_rsync-0.2.0 lib/capistrano/bundle_rsync/local_git.rb