Class: Capistrano::BundleRsync::Git
- Inherits:
-
SCM
- Object
- SimpleDelegator
- Base
- SCM
- Capistrano::BundleRsync::Git
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
Instance Method Details
#check ⇒ Object
5
6
7
8
|
# File 'lib/capistrano/bundle_rsync/git.rb', line 5
def check
exit 1 unless execute("git ls-remote #{repo_url} HEAD")
execute("mkdir -p #{config.local_base_path}")
end
|
#clean_release ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/capistrano/bundle_rsync/git.rb', line 38
def clean_release
return if fetch(:bundle_rsync_local_release_path)
releases = capture(:ls, '-x', config.local_releases_path).split
if releases.count >= config.keep_releases
directories = (releases - releases.last(config.keep_releases))
if directories.any?
directories_str = directories.map do |release|
File.join(config.local_releases_path, release)
end.join(" ")
execute :rm, '-rf', directories_str
end
end
end
|
#clone ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/capistrano/bundle_rsync/git.rb', line 10
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_release ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/capistrano/bundle_rsync/git.rb', line 24
def create_release
execute "mkdir -p #{config.local_release_path}"
within config.local_mirror_path do
if tree = fetch(:repo_tree)
stripped = tree.slice %r#^/?(.*?)/?$#, 1 num_components = stripped.count('/') + 1
execute :git, :archive, fetch(:branch), tree, "| tar -x --strip-components #{num_components} -f - -C ", "#{config.local_release_path}"
else
execute :git, :archive, fetch(:branch), '| tar -x -C', "#{config.local_release_path}"
end
end
end
|
#rsync_release ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/capistrano/bundle_rsync/git.rb', line 54
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)
execute :rsync, "#{rsync_options} --rsh='#{ssh}' #{config.local_release_path}/ #{host}:#{release_path}/"
end
end
|
#set_current_revision ⇒ Object
63
64
65
66
67
|
# File 'lib/capistrano/bundle_rsync/git.rb', line 63
def set_current_revision
within config.local_mirror_path do
set :current_revision, capture(:git, "rev-list --max-count=1 #{fetch(:branch)}")
end
end
|
#update ⇒ Object
18
19
20
21
22
|
# File 'lib/capistrano/bundle_rsync/git.rb', line 18
def update
within config.local_mirror_path do
execute :git, :remote, :update, '--prune'
end
end
|