capistrano 2.15.11 → 3.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +17 -8
  3. data/Gemfile +1 -12
  4. data/LICENSE.txt +18 -0
  5. data/README.md +65 -68
  6. data/Rakefile +4 -10
  7. data/bin/cap +2 -3
  8. data/bin/capify +7 -91
  9. data/capistrano.gemspec +20 -34
  10. data/lib/Capfile +2 -0
  11. data/lib/capistrano/application.rb +28 -0
  12. data/lib/capistrano/bundler.rb +1 -0
  13. data/lib/capistrano/configuration/question.rb +42 -0
  14. data/lib/capistrano/configuration/server.rb +24 -0
  15. data/lib/capistrano/configuration/servers.rb +43 -95
  16. data/lib/capistrano/configuration.rb +81 -44
  17. data/lib/capistrano/console.rb +1 -0
  18. data/lib/capistrano/defaults.rb +11 -0
  19. data/lib/capistrano/deploy.rb +3 -0
  20. data/lib/capistrano/dotfile.rb +3 -0
  21. data/lib/capistrano/dsl/env.rb +57 -0
  22. data/lib/capistrano/dsl/paths.rb +74 -0
  23. data/lib/capistrano/dsl/stages.rb +15 -0
  24. data/lib/capistrano/dsl/task_enhancements.rb +15 -0
  25. data/lib/capistrano/dsl.rb +38 -0
  26. data/lib/capistrano/git.rb +1 -0
  27. data/lib/capistrano/i18n.rb +33 -0
  28. data/lib/capistrano/install.rb +1 -0
  29. data/lib/capistrano/setup.rb +17 -0
  30. data/lib/capistrano/tasks/bundler.rake +13 -0
  31. data/lib/capistrano/tasks/console.rake +21 -0
  32. data/lib/capistrano/tasks/deploy.rake +153 -0
  33. data/lib/capistrano/tasks/framework.rake +45 -0
  34. data/lib/capistrano/tasks/git.rake +65 -0
  35. data/lib/capistrano/tasks/install.rake +39 -0
  36. data/lib/capistrano/templates/Capfile +43 -0
  37. data/lib/capistrano/templates/deploy.rb.erb +17 -0
  38. data/lib/capistrano/templates/stage.rb.erb +20 -0
  39. data/lib/capistrano/version.rb +1 -11
  40. data/lib/capistrano.rb +9 -3
  41. data/spec/lib/capistrano/configuration/question_spec.rb +54 -0
  42. data/spec/lib/capistrano/configuration/server_spec.rb +48 -0
  43. data/spec/lib/capistrano/configuration/servers_spec.rb +79 -0
  44. data/spec/lib/capistrano/configuration_spec.rb +80 -0
  45. data/spec/lib/capistrano/dsl/env_spec.rb +83 -0
  46. data/spec/lib/capistrano/dsl/paths_spec.rb +69 -0
  47. data/spec/lib/capistrano/dsl_spec.rb +51 -0
  48. data/spec/lib/capistrano_spec.rb +8 -0
  49. data/spec/spec_helper.rb +14 -0
  50. metadata +89 -215
  51. data/.travis.yml +0 -9
  52. data/CHANGELOG +0 -1203
  53. data/lib/capistrano/callback.rb +0 -45
  54. data/lib/capistrano/cli/execute.rb +0 -85
  55. data/lib/capistrano/cli/help.rb +0 -125
  56. data/lib/capistrano/cli/help.txt +0 -81
  57. data/lib/capistrano/cli/options.rb +0 -243
  58. data/lib/capistrano/cli/ui.rb +0 -40
  59. data/lib/capistrano/cli.rb +0 -47
  60. data/lib/capistrano/command.rb +0 -303
  61. data/lib/capistrano/configuration/actions/file_transfer.rb +0 -50
  62. data/lib/capistrano/configuration/actions/inspect.rb +0 -46
  63. data/lib/capistrano/configuration/actions/invocation.rb +0 -329
  64. data/lib/capistrano/configuration/alias_task.rb +0 -26
  65. data/lib/capistrano/configuration/callbacks.rb +0 -147
  66. data/lib/capistrano/configuration/connections.rb +0 -237
  67. data/lib/capistrano/configuration/execution.rb +0 -142
  68. data/lib/capistrano/configuration/loading.rb +0 -205
  69. data/lib/capistrano/configuration/log_formatters.rb +0 -75
  70. data/lib/capistrano/configuration/namespaces.rb +0 -223
  71. data/lib/capistrano/configuration/roles.rb +0 -83
  72. data/lib/capistrano/configuration/variables.rb +0 -127
  73. data/lib/capistrano/errors.rb +0 -19
  74. data/lib/capistrano/ext/multistage.rb +0 -67
  75. data/lib/capistrano/ext/string.rb +0 -5
  76. data/lib/capistrano/extensions.rb +0 -57
  77. data/lib/capistrano/fix_rake_deprecated_dsl.rb +0 -8
  78. data/lib/capistrano/logger.rb +0 -166
  79. data/lib/capistrano/processable.rb +0 -55
  80. data/lib/capistrano/recipes/compat.rb +0 -32
  81. data/lib/capistrano/recipes/deploy/assets.rb +0 -202
  82. data/lib/capistrano/recipes/deploy/dependencies.rb +0 -44
  83. data/lib/capistrano/recipes/deploy/local_dependency.rb +0 -54
  84. data/lib/capistrano/recipes/deploy/remote_dependency.rb +0 -117
  85. data/lib/capistrano/recipes/deploy/scm/accurev.rb +0 -169
  86. data/lib/capistrano/recipes/deploy/scm/base.rb +0 -200
  87. data/lib/capistrano/recipes/deploy/scm/bzr.rb +0 -86
  88. data/lib/capistrano/recipes/deploy/scm/cvs.rb +0 -153
  89. data/lib/capistrano/recipes/deploy/scm/darcs.rb +0 -96
  90. data/lib/capistrano/recipes/deploy/scm/git.rb +0 -299
  91. data/lib/capistrano/recipes/deploy/scm/mercurial.rb +0 -137
  92. data/lib/capistrano/recipes/deploy/scm/none.rb +0 -55
  93. data/lib/capistrano/recipes/deploy/scm/perforce.rb +0 -152
  94. data/lib/capistrano/recipes/deploy/scm/subversion.rb +0 -121
  95. data/lib/capistrano/recipes/deploy/scm.rb +0 -19
  96. data/lib/capistrano/recipes/deploy/strategy/base.rb +0 -92
  97. data/lib/capistrano/recipes/deploy/strategy/checkout.rb +0 -20
  98. data/lib/capistrano/recipes/deploy/strategy/copy.rb +0 -338
  99. data/lib/capistrano/recipes/deploy/strategy/export.rb +0 -20
  100. data/lib/capistrano/recipes/deploy/strategy/remote.rb +0 -52
  101. data/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +0 -57
  102. data/lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb +0 -21
  103. data/lib/capistrano/recipes/deploy/strategy.rb +0 -20
  104. data/lib/capistrano/recipes/deploy.rb +0 -625
  105. data/lib/capistrano/recipes/standard.rb +0 -37
  106. data/lib/capistrano/recipes/templates/maintenance.rhtml +0 -53
  107. data/lib/capistrano/role.rb +0 -102
  108. data/lib/capistrano/server_definition.rb +0 -56
  109. data/lib/capistrano/shell.rb +0 -265
  110. data/lib/capistrano/ssh.rb +0 -95
  111. data/lib/capistrano/task_definition.rb +0 -77
  112. data/lib/capistrano/transfer.rb +0 -218
  113. data/test/cli/execute_test.rb +0 -132
  114. data/test/cli/help_test.rb +0 -165
  115. data/test/cli/options_test.rb +0 -329
  116. data/test/cli/ui_test.rb +0 -28
  117. data/test/cli_test.rb +0 -17
  118. data/test/command_test.rb +0 -322
  119. data/test/configuration/actions/file_transfer_test.rb +0 -61
  120. data/test/configuration/actions/inspect_test.rb +0 -76
  121. data/test/configuration/actions/invocation_test.rb +0 -306
  122. data/test/configuration/alias_task_test.rb +0 -118
  123. data/test/configuration/callbacks_test.rb +0 -201
  124. data/test/configuration/connections_test.rb +0 -439
  125. data/test/configuration/execution_test.rb +0 -175
  126. data/test/configuration/loading_test.rb +0 -148
  127. data/test/configuration/namespace_dsl_test.rb +0 -332
  128. data/test/configuration/roles_test.rb +0 -157
  129. data/test/configuration/servers_test.rb +0 -183
  130. data/test/configuration/variables_test.rb +0 -190
  131. data/test/configuration_test.rb +0 -77
  132. data/test/deploy/local_dependency_test.rb +0 -76
  133. data/test/deploy/remote_dependency_test.rb +0 -146
  134. data/test/deploy/scm/accurev_test.rb +0 -23
  135. data/test/deploy/scm/base_test.rb +0 -55
  136. data/test/deploy/scm/bzr_test.rb +0 -51
  137. data/test/deploy/scm/darcs_test.rb +0 -37
  138. data/test/deploy/scm/git_test.rb +0 -274
  139. data/test/deploy/scm/mercurial_test.rb +0 -134
  140. data/test/deploy/scm/none_test.rb +0 -35
  141. data/test/deploy/scm/perforce_test.rb +0 -23
  142. data/test/deploy/scm/subversion_test.rb +0 -68
  143. data/test/deploy/strategy/copy_test.rb +0 -360
  144. data/test/extensions_test.rb +0 -69
  145. data/test/fixtures/cli_integration.rb +0 -5
  146. data/test/fixtures/config.rb +0 -5
  147. data/test/fixtures/custom.rb +0 -3
  148. data/test/logger_formatting_test.rb +0 -149
  149. data/test/logger_test.rb +0 -134
  150. data/test/recipes_test.rb +0 -25
  151. data/test/role_test.rb +0 -11
  152. data/test/server_definition_test.rb +0 -121
  153. data/test/shell_test.rb +0 -96
  154. data/test/ssh_test.rb +0 -113
  155. data/test/task_definition_test.rb +0 -117
  156. data/test/transfer_test.rb +0 -168
  157. data/test/utils.rb +0 -37
  158. data/test/version_test.rb +0 -11
@@ -1,338 +0,0 @@
1
- require 'capistrano/recipes/deploy/strategy/base'
2
- require 'fileutils'
3
- require 'tempfile' # Dir.tmpdir
4
-
5
- module Capistrano
6
- module Deploy
7
- module Strategy
8
-
9
- # This class implements the strategy for deployments which work
10
- # by preparing the source code locally, compressing it, copying the
11
- # file to each target host, and uncompressing it to the deployment
12
- # directory.
13
- #
14
- # By default, the SCM checkout command is used to obtain the local copy
15
- # of the source code. If you would rather use the export operation,
16
- # you can set the :copy_strategy variable to :export.
17
- #
18
- # set :copy_strategy, :export
19
- #
20
- # For even faster deployments, you can set the :copy_cache variable to
21
- # true. This will cause deployments to do a new checkout of your
22
- # repository to a new directory, and then copy that checkout. Subsequent
23
- # deploys will just resync that copy, rather than doing an entirely new
24
- # checkout. Additionally, you can specify file patterns to exclude from
25
- # the copy when using :copy_cache; just set the :copy_exclude variable
26
- # to a file glob (or an array of globs).
27
- #
28
- # set :copy_cache, true
29
- # set :copy_exclude, ".git/*"
30
- #
31
- # Note that :copy_strategy is ignored when :copy_cache is set. Also, if
32
- # you want the copy cache put somewhere specific, you can set the variable
33
- # to the path you want, instead of merely 'true':
34
- #
35
- # set :copy_cache, "/tmp/caches/myapp"
36
- #
37
- # This deployment strategy also supports a special variable,
38
- # :copy_compression, which must be one of :gzip, :bz2, or
39
- # :zip, and which specifies how the source should be compressed for
40
- # transmission to each host.
41
- #
42
- # By default, files will be transferred across to the remote machines via 'sftp'. If you prefer
43
- # to use 'scp' you can set the :copy_via variable to :scp.
44
- #
45
- # set :copy_via, :scp
46
- #
47
- # There is a possibility to pass a build command that will get
48
- # executed if your code needs to be compiled or something needs to be
49
- # done before the code is ready to run.
50
- #
51
- # set :build_script, "make all"
52
- #
53
- # Note that if you use :copy_cache, the :build_script is used on the
54
- # cache and thus you get faster compilation if your script does not
55
- # recompile everything.
56
- class Copy < Base
57
- # Obtains a copy of the source code locally (via the #command method),
58
- # compresses it to a single file, copies that file to all target
59
- # servers, and uncompresses it on each of them into the deployment
60
- # directory.
61
- def deploy!
62
- copy_cache ? run_copy_cache_strategy : run_copy_strategy
63
-
64
- create_revision_file
65
- compress_repository
66
- distribute!
67
- ensure
68
- rollback_changes
69
- end
70
-
71
- def build directory
72
- execute "running build script on #{directory}" do
73
- Dir.chdir(directory) { system(build_script) }
74
- end if build_script
75
- end
76
-
77
- def check!
78
- super.check do |d|
79
- d.local.command(source.local.command) if source.local.command
80
- d.local.command(compress(nil, nil).first)
81
- d.remote.command(decompress(nil).first)
82
- end
83
- end
84
-
85
- # Returns the location of the local copy cache, if the strategy should
86
- # use a local cache + copy instead of a new checkout/export every
87
- # time. Returns +nil+ unless :copy_cache has been set. If :copy_cache
88
- # is +true+, a default cache location will be returned.
89
- def copy_cache
90
- @copy_cache ||= configuration[:copy_cache] == true ?
91
- File.expand_path(configuration[:application], Dir.tmpdir) :
92
- File.expand_path(configuration[:copy_cache], Dir.pwd) rescue nil
93
- end
94
-
95
- private
96
-
97
- def run_copy_cache_strategy
98
- copy_repository_to_local_cache
99
- build copy_cache
100
- copy_cache_to_staging_area
101
- end
102
-
103
- def run_copy_strategy
104
- copy_repository_to_server
105
- build destination
106
- remove_excluded_files if copy_exclude.any?
107
- end
108
-
109
- def execute description, &block
110
- logger.debug description
111
- handle_system_errors &block
112
- end
113
-
114
- def handle_system_errors &block
115
- block.call
116
- raise_command_failed if last_command_failed?
117
- end
118
-
119
- def refresh_local_cache
120
- execute "refreshing local cache to revision #{revision} at #{copy_cache}" do
121
- system(source.sync(revision, copy_cache))
122
- end
123
- end
124
-
125
- def create_local_cache
126
- execute "preparing local cache at #{copy_cache}" do
127
- system(source.checkout(revision, copy_cache))
128
- end
129
- end
130
-
131
- def raise_command_failed
132
- raise Capistrano::Error, "shell command failed with return code #{$?}"
133
- end
134
-
135
- def last_command_failed?
136
- $? != 0
137
- end
138
-
139
- def copy_cache_to_staging_area
140
- execute "copying cache to deployment staging area #{destination}" do
141
- create_destination
142
- Dir.chdir(copy_cache) { copy_files(queue_files) }
143
- end
144
- end
145
-
146
- def create_destination
147
- FileUtils.mkdir_p(destination)
148
- end
149
-
150
- def copy_files files
151
- files.each { |name| process_file(name) }
152
- end
153
-
154
- def process_file name
155
- send "copy_#{filetype(name)}", name
156
- end
157
-
158
- def filetype name
159
- filetype = File.ftype name
160
- filetype = "file" unless ["link", "directory"].include? filetype
161
- filetype
162
- end
163
-
164
- def copy_link name
165
- FileUtils.ln_s(File.readlink(name), File.join(destination, name))
166
- end
167
-
168
- def copy_directory name
169
- FileUtils.mkdir(File.join(destination, name))
170
- copy_files(queue_files(name))
171
- end
172
-
173
- def copy_file name
174
- FileUtils.ln(name, File.join(destination, name))
175
- end
176
-
177
- def queue_files directory=nil
178
- Dir.glob(pattern_for(directory), File::FNM_DOTMATCH).reject! { |file| excluded_files_contain? file }
179
- end
180
-
181
- def pattern_for directory
182
- !directory.nil? ? "#{escape_globs(directory)}/*" : "*"
183
- end
184
-
185
- def escape_globs path
186
- path.gsub(/[*?{}\[\]]/, '\\\\\\&')
187
- end
188
-
189
- def excluded_files_contain? file
190
- copy_exclude.any? { |p| File.fnmatch(p, file) } or [ ".", ".."].include? File.basename(file)
191
- end
192
-
193
- def copy_repository_to_server
194
- execute "getting (via #{copy_strategy}) revision #{revision} to #{destination}" do
195
- copy_repository_via_strategy
196
- end
197
- end
198
-
199
- def copy_repository_via_strategy
200
- system(command)
201
- end
202
-
203
- def remove_excluded_files
204
- logger.debug "processing exclusions..."
205
-
206
- copy_exclude.each do |pattern|
207
- delete_list = Dir.glob(File.join(destination, pattern), File::FNM_DOTMATCH)
208
- # avoid the /.. trap that deletes the parent directories
209
- delete_list.delete_if { |dir| dir =~ /\/\.\.$/ }
210
- FileUtils.rm_rf(delete_list.compact)
211
- end
212
- end
213
-
214
- def create_revision_file
215
- File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) }
216
- end
217
-
218
- def compress_repository
219
- execute "Compressing #{destination} to #{filename}" do
220
- Dir.chdir(copy_dir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) }
221
- end
222
- end
223
-
224
- def rollback_changes
225
- FileUtils.rm filename rescue nil
226
- FileUtils.rm_rf destination rescue nil
227
- end
228
-
229
- def copy_repository_to_local_cache
230
- return refresh_local_cache if File.exist?(copy_cache)
231
- create_local_cache
232
- end
233
-
234
- def build_script
235
- configuration[:build_script]
236
- end
237
-
238
- # Specify patterns to exclude from the copy. This is only valid
239
- # when using a local cache.
240
- def copy_exclude
241
- @copy_exclude ||= Array(configuration.fetch(:copy_exclude, []))
242
- end
243
-
244
- # Returns the basename of the release_path, which will be used to
245
- # name the local copy and archive file.
246
- def destination
247
- @destination ||= File.join(copy_dir, File.basename(configuration[:release_path]))
248
- end
249
-
250
- # Returns the value of the :copy_strategy variable, defaulting to
251
- # :checkout if it has not been set.
252
- def copy_strategy
253
- @copy_strategy ||= configuration.fetch(:copy_strategy, :checkout)
254
- end
255
-
256
- # Should return the command(s) necessary to obtain the source code
257
- # locally.
258
- def command
259
- @command ||= case copy_strategy
260
- when :checkout
261
- source.checkout(revision, destination)
262
- when :export
263
- source.export(revision, destination)
264
- end
265
- end
266
-
267
- # Returns the name of the file that the source code will be
268
- # compressed to.
269
- def filename
270
- @filename ||= File.join(copy_dir, "#{File.basename(destination)}.#{compression.extension}")
271
- end
272
-
273
- # The directory to which the copy should be checked out
274
- def copy_dir
275
- @copy_dir ||= File.expand_path(configuration[:copy_dir] || Dir.tmpdir, Dir.pwd)
276
- end
277
-
278
- # The directory on the remote server to which the archive should be
279
- # copied
280
- def remote_dir
281
- @remote_dir ||= configuration[:copy_remote_dir] || "/tmp"
282
- end
283
-
284
- # The location on the remote server where the file should be
285
- # temporarily stored.
286
- def remote_filename
287
- @remote_filename ||= File.join(remote_dir, File.basename(filename))
288
- end
289
-
290
- # A struct for representing the specifics of a compression type.
291
- # Commands are arrays, where the first element is the utility to be
292
- # used to perform the compression or decompression.
293
- Compression = Struct.new(:extension, :compress_command, :decompress_command)
294
-
295
- # The compression method to use, defaults to :gzip.
296
- def compression
297
- remote_tar = configuration[:copy_remote_tar] || 'tar'
298
- local_tar = configuration[:copy_local_tar] || 'tar'
299
-
300
- type = configuration[:copy_compression] || :gzip
301
- case type
302
- when :gzip, :gz then Compression.new("tar.gz", [local_tar, 'czf'], [remote_tar, 'xzf'])
303
- when :bzip2, :bz2 then Compression.new("tar.bz2", [local_tar, 'cjf'], [remote_tar, 'xjf'])
304
- when :zip then Compression.new("zip", %w(zip -qyr), %w(unzip -q))
305
- else raise ArgumentError, "invalid compression type #{type.inspect}"
306
- end
307
- end
308
-
309
- # Returns the command necessary to compress the given directory
310
- # into the given file.
311
- def compress(directory, file)
312
- compression.compress_command + [file, directory]
313
- end
314
-
315
- # Returns the command necessary to decompress the given file,
316
- # relative to the current working directory. It must also
317
- # preserve the directory structure in the file.
318
- def decompress(file)
319
- compression.decompress_command + [file]
320
- end
321
-
322
- def decompress_remote_file
323
- run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}"
324
- end
325
-
326
- # Distributes the file to the remote servers
327
- def distribute!
328
- args = [filename, remote_filename]
329
- args << { :via => configuration[:copy_via] } if configuration[:copy_via]
330
-
331
- upload(*args)
332
- decompress_remote_file
333
- end
334
- end
335
-
336
- end
337
- end
338
- end
@@ -1,20 +0,0 @@
1
- require 'capistrano/recipes/deploy/strategy/remote'
2
-
3
- module Capistrano
4
- module Deploy
5
- module Strategy
6
-
7
- # Implements the deployment strategy which does an SCM export on each
8
- # target host.
9
- class Export < Remote
10
- protected
11
-
12
- # Returns the SCM's export command for the revision to deploy.
13
- def command
14
- @command ||= source.export(revision, configuration[:release_path])
15
- end
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,52 +0,0 @@
1
- require 'capistrano/recipes/deploy/strategy/base'
2
-
3
- module Capistrano
4
- module Deploy
5
- module Strategy
6
-
7
- # An abstract superclass, which forms the base for all deployment
8
- # strategies which work by grabbing the code from the repository directly
9
- # from remote host. This includes deploying by checkout (the default),
10
- # and deploying by export.
11
- class Remote < Base
12
- # Executes the SCM command for this strategy and writes the REVISION
13
- # mark file to each host.
14
- def deploy!
15
- scm_run "#{command} && #{mark}"
16
- end
17
-
18
- def check!
19
- super.check do |d|
20
- d.remote.command(source.command)
21
- end
22
- end
23
-
24
- protected
25
-
26
- # Runs the given command, filtering output back through the
27
- # #handle_data filter of the SCM implementation.
28
- def scm_run(command)
29
- run(command) do |ch,stream,text|
30
- ch[:state] ||= { :channel => ch }
31
- output = source.handle_data(ch[:state], stream, text)
32
- ch.send_data(output) if output
33
- end
34
- end
35
-
36
- # An abstract method which must be overridden in subclasses, to
37
- # return the actual SCM command(s) which must be executed on each
38
- # target host in order to perform the deployment.
39
- def command
40
- raise NotImplementedError, "`command' is not implemented by #{self.class.name}"
41
- end
42
-
43
- # Returns the command which will write the identifier of the
44
- # revision being deployed to the REVISION file on each host.
45
- def mark
46
- "(echo #{revision} > #{configuration[:release_path]}/REVISION)"
47
- end
48
- end
49
-
50
- end
51
- end
52
- end
@@ -1,57 +0,0 @@
1
- require 'capistrano/recipes/deploy/strategy/remote'
2
-
3
- module Capistrano
4
- module Deploy
5
- module Strategy
6
-
7
- # Implements the deployment strategy that keeps a cached checkout of
8
- # the source code on each remote server. Each deploy simply updates the
9
- # cached checkout, and then does a copy from the cached copy to the
10
- # final deployment location.
11
- class RemoteCache < Remote
12
- # Executes the SCM command for this strategy and writes the REVISION
13
- # mark file to each host.
14
- def deploy!
15
- update_repository_cache
16
- copy_repository_cache
17
- end
18
-
19
- def check!
20
- super.check do |d|
21
- d.remote.command("rsync") unless copy_exclude.empty?
22
- d.remote.writable(shared_path)
23
- end
24
- end
25
-
26
- private
27
-
28
- def repository_cache
29
- File.join(shared_path, configuration[:repository_cache] || "cached-copy")
30
- end
31
-
32
- def update_repository_cache
33
- logger.trace "updating the cached checkout on all servers"
34
- command = "if [ -d #{repository_cache} ]; then " +
35
- "#{source.sync(revision, repository_cache)}; " +
36
- "else #{source.checkout(revision, repository_cache)}; fi"
37
- scm_run(command)
38
- end
39
-
40
- def copy_repository_cache
41
- logger.trace "copying the cached version to #{configuration[:release_path]}"
42
- if copy_exclude.empty?
43
- run "cp -RPp #{repository_cache} #{configuration[:release_path]} && #{mark}"
44
- else
45
- exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ')
46
- run "rsync -lrpt #{exclusions} #{repository_cache}/ #{configuration[:release_path]} && #{mark}"
47
- end
48
- end
49
-
50
- def copy_exclude
51
- @copy_exclude ||= Array(configuration.fetch(:copy_exclude, []))
52
- end
53
- end
54
-
55
- end
56
- end
57
- end
@@ -1,21 +0,0 @@
1
- require 'capistrano/recipes/deploy/strategy/remote_cache'
2
-
3
- module Capistrano
4
- module Deploy
5
- module Strategy
6
- class UnsharedRemoteCache < RemoteCache
7
- def check!
8
- super.check do |d|
9
- d.remote.writable(repository_cache)
10
- end
11
- end
12
-
13
- private
14
-
15
- def repository_cache
16
- configuration[:repository_cache]
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,20 +0,0 @@
1
- module Capistrano
2
- module Deploy
3
- module Strategy
4
- def self.new(strategy, config={})
5
- strategy_file = "capistrano/recipes/deploy/strategy/#{strategy}"
6
- strategy_const = strategy.to_s.capitalize.gsub(/_(.)/) { $1.upcase }
7
-
8
- require(strategy_file) unless const_defined?(strategy_const)
9
-
10
- if const_defined?(strategy_const)
11
- const_get(strategy_const).new(config)
12
- else
13
- raise Capistrano::Error, "could not find `#{name}::#{strategy_const}' in `#{strategy_file}'"
14
- end
15
- rescue LoadError
16
- raise Capistrano::Error, "could not find any strategy named `#{strategy}'"
17
- end
18
- end
19
- end
20
- end