Class: Capistrano::BundleRsync::Git

Inherits:
SCM
  • Object
show all
Defined in:
lib/capistrano/bundle_rsync/git.rb

Instance Method Summary collapse

Methods inherited from SCM

#rsync_shared, #test

Methods inherited from Base

#config, #initialize

Constructor Details

This class inherits a constructor from Capistrano::BundleRsync::Base

Instance Method Details

#checkObject



4
5
6
7
# File 'lib/capistrano/bundle_rsync/git.rb', line 4

def check
  exit 1 unless execute("git ls-remote #{repo_url}")
  execute("mkdir -p #{config.local_base_path}")
end

#cloneObject



9
10
11
12
13
14
15
# File 'lib/capistrano/bundle_rsync/git.rb', line 9

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

#create_releaseObject



23
24
25
26
27
28
29
# File 'lib/capistrano/bundle_rsync/git.rb', line 23

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

#rsync_releaseObject



31
32
33
34
35
36
37
38
# File 'lib/capistrano/bundle_rsync/git.rb', line 31

def rsync_release
  hosts = 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)
    execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_release_path}/ #{host}:#{release_path}/"
  end
end

#set_current_revisionObject



40
41
42
43
44
# File 'lib/capistrano/bundle_rsync/git.rb', line 40

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

#updateObject



17
18
19
20
21
# File 'lib/capistrano/bundle_rsync/git.rb', line 17

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