capistrano_rsync_with_remote_cache 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'capistrano/recipes/deploy/strategy/remote'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
module Capistrano
|
4
5
|
module Deploy
|
@@ -72,10 +73,14 @@ module Capistrano
|
|
72
73
|
#
|
73
74
|
# TODO: punt in some sensible way if local_cache exists but is a regular file.
|
74
75
|
def command
|
75
|
-
if
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
if configuration[:scm] == :subversion
|
77
|
+
svn_info = IO.popen("svn info #{local_cache} | sed -n 's/URL: //p'")
|
78
|
+
svn_url = svn_info.gets.chomp
|
79
|
+
svn_info.close
|
80
|
+
if svn_url != configuration[:repository]
|
81
|
+
logger.trace "repository has changed; removing old local cache"
|
82
|
+
FileUtils.rm_rf local_cache
|
83
|
+
end
|
79
84
|
end
|
80
85
|
if File.exists?(local_cache) && File.directory?(local_cache)
|
81
86
|
logger.trace "updating local cache to revision #{revision}"
|
@@ -9,20 +9,21 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
|
|
9
9
|
@rwrc.expects(:configuration).at_least_once.returns(hash)
|
10
10
|
end
|
11
11
|
|
12
|
+
def stub_creation_of_new_local_cache
|
13
|
+
File.expects(:exists?).with('.rsync_cache').times(2).returns(false)
|
14
|
+
File.expects(:directory?).with(File.dirname('.rsync_cache')).returns(false)
|
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
|
+
|
12
21
|
context 'RsyncWithRemoteCache' do
|
13
22
|
setup do
|
14
23
|
@rwrc = Capistrano::Deploy::Strategy::RsyncWithRemoteCache.new
|
15
|
-
|
16
24
|
logger_stub = stub()
|
17
25
|
logger_stub.stubs(:trace)
|
18
26
|
@rwrc.stubs(:logger).returns(logger_stub)
|
19
|
-
|
20
|
-
# FIXME: this is lame
|
21
|
-
class << @rwrc
|
22
|
-
def `(cmd)
|
23
|
-
'\n'
|
24
|
-
end
|
25
|
-
end
|
26
27
|
end
|
27
28
|
|
28
29
|
should 'deploy!' do
|
@@ -116,22 +117,19 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
|
|
116
117
|
end
|
117
118
|
|
118
119
|
context 'command' do
|
119
|
-
should '
|
120
|
-
stub_configuration(:scm => :subversion)
|
120
|
+
should 'recreate local cache if it detects subversion info has changed' do
|
121
|
+
stub_configuration(:scm => :subversion, :repository => 'repository')
|
121
122
|
|
122
|
-
|
123
|
-
|
123
|
+
svn_info_stub = stub()
|
124
|
+
svn_info_stub.expects(:gets).returns("URL: url\n")
|
125
|
+
svn_info_stub.expects(:close)
|
126
|
+
IO.expects(:popen).with("svn info .rsync_cache | sed -n 's/URL: //p'").returns(svn_info_stub)
|
124
127
|
|
125
|
-
|
126
|
-
File.expects(:directory?).with(File.dirname('.rsync_cache')).returns(false)
|
127
|
-
Dir.expects(:mkdir).with(File.dirname('.rsync_cache'))
|
128
|
+
FileUtils.expects(:rm_rf).with('.rsync_cache')
|
128
129
|
|
129
|
-
|
130
|
-
source_stub.expects(:checkout)
|
131
|
-
@rwrc.expects(:source).returns(source_stub)
|
130
|
+
stub_creation_of_new_local_cache
|
132
131
|
|
133
132
|
@rwrc.send(:command)
|
134
|
-
|
135
133
|
end
|
136
134
|
|
137
135
|
should 'update local cache if it exists' do
|
@@ -144,13 +142,8 @@ class CapistranoRsyncWithRemoteCacheTest < Test::Unit::TestCase
|
|
144
142
|
@rwrc.send(:command)
|
145
143
|
end
|
146
144
|
|
147
|
-
should '
|
148
|
-
|
149
|
-
File.expects(:directory?).with(File.dirname('.rsync_cache')).returns(false)
|
150
|
-
Dir.expects(:mkdir).with(File.dirname('.rsync_cache'))
|
151
|
-
source_stub = stub()
|
152
|
-
source_stub.expects(:checkout)
|
153
|
-
@rwrc.expects(:source).returns(source_stub)
|
145
|
+
should 'create local cache if it does not exist' do
|
146
|
+
stub_creation_of_new_local_cache
|
154
147
|
|
155
148
|
@rwrc.send(:command)
|
156
149
|
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.2
|
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-05-
|
12
|
+
date: 2009-05-15 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|