capistrano_rsync_with_remote_cache 2.3.4 → 2.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/README.rdoc +2 -2
- data/Rakefile +34 -39
- data/VERSION +1 -0
- data/capistrano_rsync_with_remote_cache.gemspec +55 -0
- data/lib/capistrano/recipes/deploy/strategy/exceptions.reek +15 -0
- data/lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb +30 -30
- data/test/capistrano_rsync_with_remote_cache_test.rb +35 -36
- metadata +8 -4
- data/VERSION.yml +0 -4
data/.document
ADDED
data/README.rdoc
CHANGED
@@ -6,9 +6,9 @@ This gem provides a deployment strategy for Capistrano which combines rsync with
|
|
6
6
|
|
7
7
|
This gem requires Capistrano 2.0.0 or higher. Git support requires Capistrano 2.1.0 or higher.
|
8
8
|
|
9
|
-
This gem
|
9
|
+
This gem supports Subversion, Git, Mercurial and Bazaar. Only Subversion and Git have been extensively tested. This gem is unlikely to be supported for other SCM systems.
|
10
10
|
|
11
|
-
This gem requires <tt>rsync</tt> command line utilities on the local and remote hosts. It also requires either <tt>svn</tt
|
11
|
+
This gem requires <tt>rsync</tt> command line utilities on the local and remote hosts. It also requires either <tt>svn</tt>, <tt>git</tt>, <tt>hg</tt> or <hg>bzr</hg> on the local host, but not the remote host.
|
12
12
|
|
13
13
|
This gem is tested on Mac OS X and Linux. Windows is not tested or supported.
|
14
14
|
|
data/Rakefile
CHANGED
@@ -12,18 +12,21 @@ begin
|
|
12
12
|
gem.authors = ["Mark Cornick"]
|
13
13
|
gem.rubyforge_project = "viget"
|
14
14
|
gem.add_dependency 'capistrano', '>= 2.0'
|
15
|
-
|
16
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
16
|
end
|
17
|
+
|
18
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
19
|
+
rubyforge.doc_task = "yardoc"
|
20
|
+
end
|
18
21
|
rescue LoadError
|
19
|
-
puts "Jeweler not available. Install it with: sudo gem install
|
22
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
23
|
end
|
21
24
|
|
22
25
|
require 'rake/testtask'
|
23
26
|
Rake::TestTask.new(:test) do |test|
|
24
27
|
test.libs << 'lib' << 'test'
|
25
28
|
test.pattern = 'test/**/*_test.rb'
|
26
|
-
test.verbose =
|
29
|
+
test.verbose = true
|
27
30
|
end
|
28
31
|
|
29
32
|
begin
|
@@ -36,50 +39,42 @@ begin
|
|
36
39
|
end
|
37
40
|
rescue LoadError
|
38
41
|
task :rcov do
|
39
|
-
abort "RCov is not available. In order to run rcov, you must: sudo gem install
|
42
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install relevance-rcov"
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
begin
|
47
|
+
require 'reek/rake_task'
|
48
|
+
Reek::RakeTask.new do |t|
|
49
|
+
t.fail_on_error = true
|
50
|
+
t.verbose = false
|
51
|
+
t.source_files = 'lib/**/*.rb'
|
52
|
+
end
|
53
|
+
rescue LoadError
|
54
|
+
task :reek do
|
55
|
+
abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
|
53
56
|
end
|
54
|
-
|
55
|
-
rdoc.rdoc_dir = 'rdoc'
|
56
|
-
rdoc.title = "capistrano_rsync_with_remote_cache #{version}"
|
57
|
-
rdoc.rdoc_files.include('README*')
|
58
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
57
|
end
|
60
58
|
|
61
59
|
begin
|
62
|
-
require '
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
73
|
-
)
|
60
|
+
require 'roodi'
|
61
|
+
require 'roodi_task'
|
62
|
+
RoodiTask.new do |t|
|
63
|
+
t.verbose = false
|
64
|
+
end
|
65
|
+
rescue LoadError
|
66
|
+
task :roodi do
|
67
|
+
abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
|
68
|
+
end
|
69
|
+
end
|
74
70
|
|
75
|
-
|
76
|
-
remote_dir = "/var/www/gforge-projects/capistrano_rsync_with_remote_cache/"
|
77
|
-
local_dir = 'rdoc'
|
71
|
+
task :default => :test
|
78
72
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
73
|
+
begin
|
74
|
+
require 'yard'
|
75
|
+
YARD::Rake::YardocTask.new
|
83
76
|
rescue LoadError
|
84
|
-
|
77
|
+
task :yardoc do
|
78
|
+
abort "Yard is not available. In order to run yardoc, you must: sudo gem install yard"
|
79
|
+
end
|
85
80
|
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.5
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{capistrano_rsync_with_remote_cache}
|
8
|
+
s.version = "2.3.5"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Mark Cornick"]
|
12
|
+
s.date = %q{2009-08-07}
|
13
|
+
s.description = %q{A deployment strategy for Capistrano 2.0 which combines rsync with a remote cache, allowing fast deployments from SCM servers behind firewalls.}
|
14
|
+
s.email = %q{mark@viget.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"capistrano_rsync_with_remote_cache.gemspec",
|
27
|
+
"lib/capistrano/recipes/deploy/strategy/exceptions.reek",
|
28
|
+
"lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb",
|
29
|
+
"test/capistrano_rsync_with_remote_cache_test.rb",
|
30
|
+
"test/test_helper.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/vigetlabs/capistrano_rsync_with_remote_cache}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubyforge_project = %q{viget}
|
36
|
+
s.rubygems_version = %q{1.3.4}
|
37
|
+
s.summary = %q{rsync_with_remote_cache strategy for Capistrano}
|
38
|
+
s.test_files = [
|
39
|
+
"test/capistrano_rsync_with_remote_cache_test.rb",
|
40
|
+
"test/test_helper.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 3
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<capistrano>, [">= 2.0"])
|
49
|
+
else
|
50
|
+
s.add_dependency(%q<capistrano>, [">= 2.0"])
|
51
|
+
end
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<capistrano>, [">= 2.0"])
|
54
|
+
end
|
55
|
+
end
|
@@ -6,13 +6,20 @@ module Capistrano
|
|
6
6
|
module Strategy
|
7
7
|
class RsyncWithRemoteCache < Remote
|
8
8
|
|
9
|
+
INFO_COMMANDS = {
|
10
|
+
:subversion => "svn info . | sed -n \'s/URL: //p\'",
|
11
|
+
:git => "git config remote.origin.url",
|
12
|
+
:mercurial => "hg showconfig paths.default",
|
13
|
+
:bzr => "bzr info | grep parent | sed \'s/^.*parent branch: //\'"
|
14
|
+
}
|
15
|
+
|
9
16
|
# The deployment method itself, in three major steps: update the local cache, update the remote
|
10
17
|
# cache, and copy the remote cache into place.
|
11
18
|
def deploy!
|
12
19
|
|
13
20
|
# Step 1: Update the local cache.
|
14
21
|
system(command)
|
15
|
-
File.open(File.join(local_cache, "REVISION"), "w") { |
|
22
|
+
File.open(File.join(local_cache, "REVISION"), "w") { |file| file.puts(revision) }
|
16
23
|
|
17
24
|
# Step 2: Update the remote cache.
|
18
25
|
logger.trace "copying local cache to remote"
|
@@ -28,10 +35,10 @@ module Capistrano
|
|
28
35
|
# on the local end, and rsync on both ends. Note that the SCM command is not needed on the
|
29
36
|
# remote end.
|
30
37
|
def check!
|
31
|
-
super.check do |
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
super.check do |check|
|
39
|
+
check.local.command(source.command)
|
40
|
+
check.local.command('rsync')
|
41
|
+
check.remote.command('rsync')
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
@@ -63,41 +70,34 @@ module Capistrano
|
|
63
70
|
end
|
64
71
|
end
|
65
72
|
|
66
|
-
#
|
67
|
-
#
|
68
|
-
# If it matches, we update it. If it doesn't match (either it's for another repository or
|
69
|
-
# not a checkout at all), we remove the directory and recreate it with a fresh SCM checkout.
|
70
|
-
# If the directory doesn't exist, we create it with a fresh SCM checkout.
|
73
|
+
# Remove the local cache (so it can be recreated) if the repository URL has changed
|
74
|
+
# since the last deployment.
|
71
75
|
# TODO: punt in some sensible way if local_cache exists but is a regular file.
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
info_command = "echo #{configuration[:repository]}"
|
81
|
-
end
|
82
|
-
cache_info = IO.popen(info_command)
|
83
|
-
|
84
|
-
cached_repository = cache_info.gets
|
85
|
-
cache_info.close
|
86
|
-
if cached_repository && cached_repository.chomp != configuration[:repository]
|
87
|
-
logger.trace "repository has changed; removing old local cache"
|
88
|
-
FileUtils.rm_rf local_cache
|
76
|
+
def remove_cache_if_repo_changed
|
77
|
+
if INFO_COMMANDS[configuration[:scm]] && File.directory?(local_cache)
|
78
|
+
info_command = "cd #{local_cache} && #{INFO_COMMANDS[configuration[:scm]]}"
|
79
|
+
cached_repo_url = IO.popen(info_command){|pipe| pipe.readline}.chomp
|
80
|
+
if cached_repo_url != configuration[:repository]
|
81
|
+
logger.trace "repository has changed; removing old local cache"
|
82
|
+
FileUtils.rm_rf(local_cache)
|
83
|
+
end
|
89
84
|
end
|
85
|
+
end
|
90
86
|
|
87
|
+
# Command to get source from SCM on the local side. The local cache is either created,
|
88
|
+
# updated, or destroyed and recreated depending on whether it exists and is a cache of
|
89
|
+
# the right repository.
|
90
|
+
def command
|
91
|
+
remove_cache_if_repo_changed
|
91
92
|
if File.exists?(local_cache) && File.directory?(local_cache)
|
92
93
|
logger.trace "updating local cache to revision #{revision}"
|
93
|
-
|
94
|
+
return source.sync(revision, local_cache)
|
94
95
|
else
|
95
96
|
logger.trace "creating local cache with revision #{revision}"
|
96
97
|
File.delete(local_cache) if File.exists?(local_cache)
|
97
98
|
Dir.mkdir(File.dirname(local_cache)) unless File.directory?(File.dirname(local_cache))
|
98
|
-
|
99
|
+
return source.checkout(revision, local_cache)
|
99
100
|
end
|
100
|
-
cmd
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
@@ -9,20 +9,9 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
|
|
9
9
|
@rwrc.expects(:configuration).at_least_once.returns(hash)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
File.expects(:
|
14
|
-
|
15
|
-
Dir.expects(:mkdir).with(File.dirname('.rsync_cache'))
|
16
|
-
source_stub = stub()
|
17
|
-
source_stub.expects(:checkout)
|
18
|
-
@rwrc.expects(:source).returns(source_stub)
|
19
|
-
end
|
20
|
-
|
21
|
-
def stub_detection_of_changed_local_cache(command, returns)
|
22
|
-
cache_info_stub = stub()
|
23
|
-
cache_info_stub.expects(:gets).returns(returns)
|
24
|
-
cache_info_stub.expects(:close)
|
25
|
-
IO.expects(:popen).with(command).returns(cache_info_stub)
|
12
|
+
def stub_detection_of_changed_local_cache(command, returned)
|
13
|
+
File.expects(:directory?).with('.rsync_cache').returns(true)
|
14
|
+
IO.expects(:popen).with(command).returns(returned)
|
26
15
|
end
|
27
16
|
|
28
17
|
context 'RsyncWithRemoteCache' do
|
@@ -123,56 +112,66 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
|
|
123
112
|
end
|
124
113
|
end
|
125
114
|
|
126
|
-
context '
|
115
|
+
context 'remove_cache_if_repo_changed' do
|
127
116
|
should 'purge local cache if it detects subversion info has changed' do
|
128
|
-
stub_configuration(:scm => :subversion, :repository => 'repository')
|
129
|
-
stub_detection_of_changed_local_cache("svn info .
|
117
|
+
stub_configuration(:scm => :subversion, :repository => 'repository')
|
118
|
+
stub_detection_of_changed_local_cache("cd .rsync_cache && svn info . | sed -n 's/URL: //p'", "URL: url\n")
|
130
119
|
FileUtils.expects(:rm_rf).with('.rsync_cache')
|
131
|
-
|
132
|
-
|
133
|
-
@rwrc.send(:command)
|
120
|
+
@rwrc.send(:remove_cache_if_repo_changed)
|
134
121
|
end
|
135
122
|
|
136
123
|
should 'purge local cache if it detects git info has changed' do
|
137
|
-
stub_configuration(:scm => :git, :repository => 'repository')
|
124
|
+
stub_configuration(:scm => :git, :repository => 'repository')
|
138
125
|
stub_detection_of_changed_local_cache("cd .rsync_cache && git config remote.origin.url", "beep\n")
|
139
126
|
FileUtils.expects(:rm_rf).with('.rsync_cache')
|
140
|
-
|
127
|
+
@rwrc.send(:remove_cache_if_repo_changed)
|
128
|
+
end
|
141
129
|
|
142
|
-
|
130
|
+
should 'purge local cache if it detects hg info has changed' do
|
131
|
+
stub_configuration(:scm => :mercurial, :repository => 'repository')
|
132
|
+
stub_detection_of_changed_local_cache("cd .rsync_cache && hg showconfig paths.default", "beep\n")
|
133
|
+
FileUtils.expects(:rm_rf).with('.rsync_cache')
|
134
|
+
@rwrc.send(:remove_cache_if_repo_changed)
|
135
|
+
end
|
136
|
+
|
137
|
+
should 'purge local cache if it detects bzr info has changed' do
|
138
|
+
stub_configuration(:scm => :bzr, :repository => 'repository')
|
139
|
+
stub_detection_of_changed_local_cache("cd .rsync_cache && bzr info | grep parent | sed 's/^.*parent branch: //'", "beep\n")
|
140
|
+
FileUtils.expects(:rm_rf).with('.rsync_cache')
|
141
|
+
@rwrc.send(:remove_cache_if_repo_changed)
|
143
142
|
end
|
144
143
|
|
145
144
|
should 'not attempt to purge local cache that does not exist' do
|
146
|
-
stub_configuration(:scm => :subversion, :repository => 'repository')
|
147
|
-
|
145
|
+
stub_configuration(:scm => :subversion, :repository => 'repository')
|
146
|
+
File.expects(:directory?).with('.rsync_cache').returns(false)
|
148
147
|
FileUtils.expects(:rm_rf).with('.rsync_cache').never
|
149
|
-
|
150
|
-
|
151
|
-
@rwrc.send(:command)
|
148
|
+
@rwrc.send(:remove_cache_if_repo_changed)
|
152
149
|
end
|
153
150
|
|
154
151
|
should 'not attempt to purge local cache if the scm is not supported by this gem' do
|
155
|
-
stub_configuration(:scm => :
|
156
|
-
stub_detection_of_changed_local_cache("echo repository", "repository\n")
|
152
|
+
stub_configuration(:scm => :cvs, :repository => 'repository')
|
157
153
|
FileUtils.expects(:rm_rf).with('.rsync_cache').never
|
158
|
-
|
159
|
-
|
160
|
-
@rwrc.send(:command)
|
154
|
+
@rwrc.send(:remove_cache_if_repo_changed)
|
161
155
|
end
|
156
|
+
end
|
162
157
|
|
158
|
+
context 'command' do
|
163
159
|
should 'update local cache if it exists' do
|
164
160
|
File.expects(:exists?).with('.rsync_cache').returns(true)
|
165
161
|
File.expects(:directory?).with('.rsync_cache').returns(true)
|
166
162
|
source_stub = stub()
|
167
163
|
source_stub.expects(:sync)
|
168
164
|
@rwrc.expects(:source).returns(source_stub)
|
169
|
-
|
170
165
|
@rwrc.send(:command)
|
171
166
|
end
|
172
167
|
|
173
168
|
should 'create local cache if it does not exist' do
|
174
|
-
|
175
|
-
|
169
|
+
File.expects(:exists?).with('.rsync_cache').times(2).returns(false)
|
170
|
+
File.expects(:directory?).with(File.dirname('.rsync_cache')).returns(false)
|
171
|
+
Dir.expects(:mkdir).with(File.dirname('.rsync_cache'))
|
172
|
+
source_stub = stub()
|
173
|
+
source_stub.expects(:checkout)
|
174
|
+
@rwrc.expects(:source).returns(source_stub)
|
176
175
|
@rwrc.send(:command)
|
177
176
|
end
|
178
177
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano_rsync_with_remote_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Cornick
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-07 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,10 +32,14 @@ extra_rdoc_files:
|
|
32
32
|
- LICENSE
|
33
33
|
- README.rdoc
|
34
34
|
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
35
37
|
- LICENSE
|
36
38
|
- README.rdoc
|
37
39
|
- Rakefile
|
38
|
-
- VERSION
|
40
|
+
- VERSION
|
41
|
+
- capistrano_rsync_with_remote_cache.gemspec
|
42
|
+
- lib/capistrano/recipes/deploy/strategy/exceptions.reek
|
39
43
|
- lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb
|
40
44
|
- test/capistrano_rsync_with_remote_cache_test.rb
|
41
45
|
- test/test_helper.rb
|
@@ -63,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
67
|
requirements: []
|
64
68
|
|
65
69
|
rubyforge_project: viget
|
66
|
-
rubygems_version: 1.3.
|
70
|
+
rubygems_version: 1.3.4
|
67
71
|
signing_key:
|
68
72
|
specification_version: 3
|
69
73
|
summary: rsync_with_remote_cache strategy for Capistrano
|
data/VERSION.yml
DELETED