Sha256: c12ac2d9b1cbfe6c4e0285941b9e419703b0480a1a60179f19909ac890f080af

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'capistrano/bundle_rsync/scm'

class Capistrano::BundleRsync::Git < Capistrano::BundleRsync::SCM
  def check
    exit 1 unless execute("git ls-remote #{repo_url}")
    execute("mkdir -p #{config.local_base_path}")
  end

  def clone
    if File.exist?("#{config.local_mirror_path}/HEAD")
      info t(:mirror_exists, at: config.local_mirror_path)
    else
      execute :git, :clone, '--mirror', repo_url, config.local_mirror_path
    end
  end

  def update
    within config.local_mirror_path do
      execute :git, :remote, :update
    end
  end

  def create_release
    execute "mkdir -p #{config.local_release_path}"

    within config.local_mirror_path do
      execute :git, :archive, fetch(:branch), '| tar -x -C', "#{config.local_release_path}"
    end
  end

  def rsync_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}' #{config.local_release_path}/ #{host}:#{release_path}/"
    end
  end

  def set_current_revision
    within config.local_mirror_path do
      set :current_revision, capture(:git, "rev-parse --short #{fetch(:branch)}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-bundle_rsync-0.2.3 lib/capistrano/bundle_rsync/git.rb
capistrano-bundle_rsync-0.2.2 lib/capistrano/bundle_rsync/git.rb