capistrano-wp 0.4.3 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -239,6 +239,24 @@ or your stage specific files.
239
239
  set :snapshot_allow_differences, true
240
240
  ```
241
241
 
242
+ If you would like to ignore changes to specific files, you can declare an option:
243
+
244
+ ```ruby
245
+ set :localchanges_excludes, {
246
+ :deleted => ['deleted_file_to_ignore'],
247
+ :created => ['subdirectory/createdfile'],
248
+ :changed => ['changedfile'],
249
+ :any => ['ignoredfile']
250
+ }
251
+ ```
252
+
253
+ Filenames are relative to the webroot, and are exact; there is no current provision
254
+ for globbing or directory tree exclusion. The `:any` list will ignore all changes
255
+ to a given file - deletion, creation, or content changes - while the other lists
256
+ may be useful for more limited exclusions - for instance, a file that can be deleted
257
+ but should never be changed if it remains present.
258
+
259
+
242
260
  ## Development
243
261
 
244
262
  [rubygems]: http://rubygems.org/pages/download
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.6
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "capistrano-wp"
8
- s.version = "0.4.3"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Crowd Favorite"]
12
- s.date = "2013-09-25"
12
+ s.date = "2013-11-12"
13
13
  s.description = "Recipes for deploying and maintaining remote WordPress installations with\nCapistrano. Pulls in WordPress from SVN, optionally using a local or\nremote cache, and supports a number of common operations and tasks towards\nthe care and feeding of sites that may not be 100% maintained through\nversion control.\n"
14
14
  s.executables = ["capify-wp"]
15
15
  s.extra_rdoc_files = [
@@ -40,7 +40,14 @@ module CrowdFavorite::Tasks::LocalChanges
40
40
  _cset(:hash_suffix) { "_hash" }
41
41
  _cset(:hash_compare_suffix) { "compare" }
42
42
  _cset(:hashes) { capture("ls -xt #{File.join(hash_directory, '*' + hash_suffix)}").split.reverse }
43
-
43
+ _cset(:localchanges_excludes) {
44
+ {
45
+ :deleted => [],
46
+ :created => [],
47
+ :changed => [],
48
+ :any => []
49
+ }
50
+ }
44
51
 
45
52
  def _snapshot_exists(path)
46
53
  retcode = (capture("test -f " + Shellwords::escape(path) + "; echo $?").to_s.strip.to_i)
@@ -145,11 +152,30 @@ module CrowdFavorite::Tasks::LocalChanges
145
152
  end
146
153
  end
147
154
  end
155
+ excludes = fetch(:localchanges_excludes)
156
+ excludes[:any] ||= []
157
+ logger.important "Excluding from #{current_release}: #{excludes.inspect}"
158
+ excluded = {:left => {}, :right => {}, :changed => {}}
159
+ found_exclusion = false
160
+ [[left, :deleted], [right, :created], [changed, :changed]].each do |filegroup, excluder|
161
+ excludes[excluder] ||= []
162
+ filegroup.each do |filename, servers|
163
+ if excludes[excluder].detect {|f| f == filename or File.join(current_release, f) == filename} or
164
+ excludes[:any].detect {|f| f == filename or File.join(current_release, f) == filename}
165
+ found_exclusion = true
166
+ excluded[excluder] ||= {}
167
+ excluded[excluder][filename] ||= []
168
+ excluded[excluder][filename].push(*servers)
169
+ excluded[excluder][filename].uniq!
170
+ filegroup.delete(filename)
171
+ end
172
+ end
173
+ end
148
174
 
149
175
  unset(:snapshot_target)
150
176
  unset(:snapshot_hash_path)
151
177
  unset(:snapshot_force)
152
- return {:left => left, :right => right, :changed => changed}
178
+ return {:left => left, :right => right, :changed => changed, :excluded => excluded}
153
179
  end
154
180
 
155
181
  def _do_snapshot_diff(results, format = :full)
@@ -157,13 +183,29 @@ module CrowdFavorite::Tasks::LocalChanges
157
183
  return false
158
184
  end
159
185
  if results[:left].empty? && results[:right].empty? && results[:changed].empty?
186
+ if results.has_key?(:excluded)
187
+ logger.important "excluded: " + results[:excluded].inspect
188
+ end
160
189
  return false
161
190
  end
162
191
 
163
192
  if format == :basic || !(fetch(:strategy).class <= Capistrano::Deploy::Strategy.new(:remote).class)
164
- logger.important "deleted: " + results[:left].inspect
165
- logger.important "created: " + results[:right].inspect
166
- logger.important "changed: " + results[:changed].inspect
193
+ [[:left, 'deleted'], [:right, 'created'], [:changed, 'changed']].each do |resultgroup, verb|
194
+ if !results[resultgroup].empty?
195
+ logger.important "#{verb}: "
196
+ results[resultgroup].each do |thefile, servers|
197
+ filename = thefile
198
+ if filename.start_with? current_release
199
+ filename = thefile.slice(current_release.length..-1)
200
+ end
201
+ logger.important "#{File.basename filename} in #{File.dirname filename} (on #{servers.inspect})"
202
+ end
203
+ end
204
+ end
205
+
206
+ if results.has_key?(:excluded)
207
+ logger.info "excluded: " + results[:excluded].inspect
208
+ end
167
209
  return true
168
210
  end
169
211
 
@@ -174,41 +216,10 @@ module CrowdFavorite::Tasks::LocalChanges
174
216
  logger.important "deleted: " + results[:left].inspect
175
217
  logger.important "created: " + results[:right].inspect
176
218
  logger.important "changed: " + results[:changed].inspect
177
- return true
178
-
179
- todostuff = <<-'EOTODO'
180
- File.join(shared_path, configuration[:repository_cache] || "cached-copy")
181
- if fetch(:scm) == :git
182
- if fetch(:copy_exclude, []).include?(".git")
183
- run("echo 'gitdir: #{}
184
-
185
- end
186
-
187
-
188
- run("diff " + default_hash_path + " " + snapshot_hash_path + " || true") do |channel, stream, data|
189
- data.each_line do |line|
190
- line.strip!
191
- if line.match(/^\s*[<>]/)
192
- parts = line.split(/\s+/)
193
- if hash_creation.match(/ls -ld/)
194
- # > -rw-rw-r-- 1 example example 41 Sep 19 14:58 index.php
195
- parts.slice!(0, 9)
196
- else
197
- # < 198ed94e9f1e5c69e159e8ba6d4420bb9c039715 index.php
198
- parts.slice!(0,2)
199
- end
200
-
201
- bucket = line.match(/^\s*</) ? left : right
202
- filename = parts.join('')
203
-
204
- bucket[filename] ||= []
205
- bucket[filename].push(channel[:host])
206
- end
207
- end
219
+ if results.has_key?[:excluded]
220
+ logger.important "excluded: " + results[:excluded].inspect
208
221
  end
209
- logger.important "oh hey, fully featured"
210
222
  return true
211
- EOTODO
212
223
  end
213
224
 
214
225
  desc "Check the current release for changes made on the server; abort if changes are detected."
@@ -233,7 +244,7 @@ module CrowdFavorite::Tasks::LocalChanges
233
244
  else
234
245
  logger.info "keeping #{count} of #{hashes.length} release hashes"
235
246
  hashpaths = (hashes - hashes.last(count)).map{ |thehash|
236
- File.join(hash_directory, thehash) + " " + File.join(hash_directory, thehash + hash_compare_suffix)
247
+ File.join(thehash) + " " + File.join(thehash + hash_compare_suffix)
237
248
  }.join(" ")
238
249
  try_sudo "rm -f #{hashpaths}"
239
250
  end
@@ -21,6 +21,7 @@ module CrowdFavorite::WordPress
21
21
  extend CrowdFavorite::Support::Namespace
22
22
  namespace :cf do
23
23
  after "deploy:finalize_update", "cf:localchanges:snapshot_deploy"
24
+ after "deploy:cleanup", "cf:localchanges:cleanup"
24
25
  before "deploy", "cf:localchanges:compare"
25
26
  end
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-wp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-25 00:00:00.000000000 Z
12
+ date: 2013-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano