capistrano-scm-local 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/capistrano-scm-local.gemspec +1 -1
- data/lib/capistrano/scm-local.rb +33 -32
- data/lib/capistrano/tasks/scm-local.rake +8 -2
- metadata +1 -1
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "capistrano-scm-local"
|
7
|
-
gem.version = '0.1.
|
7
|
+
gem.version = '0.1.7'
|
8
8
|
gem.authors = ["Boris Gorbylev"]
|
9
9
|
gem.email = ["ekho@ekho.name"]
|
10
10
|
gem.description = %q{Capistrano extension for deploying form local directory}
|
data/lib/capistrano/scm-local.rb
CHANGED
@@ -9,55 +9,56 @@ require 'tmpdir'
|
|
9
9
|
require 'fileutils'
|
10
10
|
|
11
11
|
class Capistrano::Local < Capistrano::SCM
|
12
|
-
module
|
12
|
+
module PlainStrategy
|
13
13
|
def check
|
14
14
|
puts repo_url
|
15
15
|
test! " [ -e #{repo_url} ] "
|
16
16
|
end
|
17
17
|
|
18
18
|
def release
|
19
|
+
file_list = Dir.glob(File.join(repo_url, '*')).concat(Dir.glob(File.join(repo_url, '.[^.]*')))
|
20
|
+
|
19
21
|
on release_roles :all, in: :parallel do |host|
|
20
|
-
|
21
|
-
|
22
|
+
file_list.each { |r| upload! r, release_path, recursive: true }
|
23
|
+
end
|
22
24
|
end
|
23
25
|
end
|
24
|
-
end
|
25
26
|
|
26
|
-
module ArchiveStrategy
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
module ArchiveStrategy
|
28
|
+
def check
|
29
|
+
test! " [ -e #{repo_url} ] "
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
def release
|
33
|
+
archive = ''
|
34
|
+
# preparing archive
|
35
|
+
run_locally do
|
36
|
+
archive = fetch(:tmp_dir, Dir::tmpdir()) + '/' + fetch(:application, 'distr') + "-#{release_timestamp}.tar.gz"
|
37
|
+
unless File.exists?(archive)
|
38
|
+
if File.directory?(repo_url) || !File.fnmatch('*.tar.gz', repo_url)
|
39
|
+
Dir.chdir(repo_url) do
|
40
|
+
Minitar.pack('.', Zlib::GzipWriter.new(File.open(archive, 'wb')))
|
41
|
+
end
|
42
|
+
else
|
43
|
+
FileUtils.cp(repo_url, archive)
|
40
44
|
end
|
41
|
-
else
|
42
|
-
FileUtils.cp(repo_url, archive)
|
43
45
|
end
|
44
46
|
end
|
45
|
-
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
# uploading and unpacking
|
49
|
+
on release_roles :all, in: :parallel do |host|
|
50
|
+
upload! archive, releases_path, verbose: false
|
51
|
+
remote_archive = File.join(releases_path, File.basename(archive))
|
52
|
+
execute :tar, 'xzf', remote_archive, '-C', release_path
|
53
|
+
execute :rm, '-f', remote_archive
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
# removing archive
|
57
|
+
run_locally do
|
58
|
+
execute :rm, '-f', archive
|
59
|
+
end
|
60
|
+
end
|
58
61
|
end
|
59
62
|
end
|
60
|
-
end
|
61
|
-
end
|
62
63
|
|
63
64
|
set :capistrano_local_archive, Capistrano::Local::ArchiveStrategy
|
@@ -1,9 +1,9 @@
|
|
1
1
|
namespace :local do
|
2
2
|
|
3
3
|
def local_strategy
|
4
|
-
strategies = {:
|
4
|
+
strategies = {:plain=>Capistrano::Local::PlainStrategy, :archive=>Capistrano::Local::ArchiveStrategy}
|
5
5
|
|
6
|
-
m = fetch(:local_strategy ? :local_strategy : :
|
6
|
+
m = fetch(:local_strategy ? :local_strategy : :archive)
|
7
7
|
unless m.is_a?(Module)
|
8
8
|
abort "Invalid local_strategy: " + m.to_s unless strategies.include?(m)
|
9
9
|
m = strategies[m]
|
@@ -28,4 +28,10 @@ namespace :local do
|
|
28
28
|
end
|
29
29
|
local_strategy.release
|
30
30
|
end
|
31
|
+
|
32
|
+
desc 'Read revision from REVISION file if exists'
|
33
|
+
task :set_current_revision do
|
34
|
+
revision_file = File.join(repo_url, 'REVISION')
|
35
|
+
set :current_revision, File.exist?(revision_file) ? File.read(revision_file).strip : 'UNKNOWN'
|
36
|
+
end
|
31
37
|
end
|