cfoundry 0.5.3.rc2 → 0.5.3.rc3

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/Rakefile CHANGED
@@ -6,33 +6,3 @@ require "cfoundry/version"
6
6
 
7
7
  RSpec::Core::RakeTask.new(:spec)
8
8
  task :default => :spec
9
-
10
- namespace :deploy do
11
- def last_staging_sha
12
- `git rev-parse latest-staging`.strip
13
- end
14
-
15
- def last_release_sha
16
- `git rev-parse latest-release`.strip
17
- end
18
-
19
- def last_staging_ref_was_released?
20
- last_staging_sha == last_release_sha
21
- end
22
-
23
- task :staging, :version do |_, args|
24
- sh "gem bump --push #{"--version #{args.version}" if args.version}" if last_staging_ref_was_released?
25
- sh "git tag -f latest-staging"
26
- sh "git push origin :latest-staging"
27
- sh "git push origin latest-staging"
28
- end
29
-
30
- task :gem do
31
- sh "git fetch"
32
- sh "git checkout #{last_staging_sha}"
33
- sh "gem release --tag"
34
- sh "git tag -f latest-release"
35
- sh "git push origin :latest-release"
36
- sh "git push origin latest-release"
37
- end
38
- end
@@ -29,8 +29,12 @@ module CcApiStub
29
29
  to_return(response(400, error_attributes))
30
30
  end
31
31
 
32
- def load_fixtures(fixtures_name, options = {})
33
- path = File.join(File.dirname(__FILE__), "..", "..", "spec/fixtures/#{fixtures_name.to_s}.json")
32
+ def load_fixtures(fixture_name_or_path, options = {})
33
+ path = if options.delete(:use_local_fixture)
34
+ fixture_name_or_path
35
+ else
36
+ File.join(File.dirname(__FILE__), "..", "..", "spec/fixtures/#{fixture_name_or_path.to_s}.json")
37
+ end
34
38
  JSON.parse(File.read(path)).tap do |fixture|
35
39
  fixture["entity"].merge!(options.stringify_keys) if options.any?
36
40
  end
@@ -59,46 +59,26 @@ module CFoundry
59
59
  elsif war_file = Dir.glob("#{path}/*.war").first
60
60
  CFoundry::Zip.unpack(war_file, to)
61
61
  else
62
- check_unreachable_links(path)
63
-
64
62
  FileUtils.mkdir(to)
65
63
 
66
- files = Dir.glob("#{path}/{*,.[^\.]*}")
67
-
68
64
  exclude = UPLOAD_EXCLUDE
69
65
  if File.exists?("#{path}/.vmcignore")
70
66
  exclude += File.read("#{path}/.vmcignore").split(/\n+/)
71
67
  end
72
68
 
73
- # prevent initial copying if we can, remove sub-files later
74
- files.reject! do |f|
75
- exclude.any? do |e|
76
- File.fnmatch(f.sub(path + "/", ""), e)
77
- end
78
- end
69
+ files = files_to_consider(path, exclude)
70
+
71
+ check_unreachable_links(files, path)
79
72
 
80
- FileUtils.cp_r(files, to)
73
+ copy_tree(files, path, to)
81
74
 
82
75
  find_sockets(to).each do |s|
83
76
  File.delete s
84
77
  end
85
-
86
- # remove ignored globs more thoroughly
87
- #
88
- # note that the above file list only includes toplevel
89
- # files/directories for cp_r, so this is where sub-files/etc. are
90
- # removed
91
- exclude.each do |e|
92
- Dir.glob("#{to}/#{e}").each do |f|
93
- FileUtils.rm_rf(f)
94
- end
95
- end
96
78
  end
97
79
  end
98
80
 
99
- def check_unreachable_links(path)
100
- files = Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
101
-
81
+ def check_unreachable_links(files, path)
102
82
  # only used for friendlier error message
103
83
  pwd = Pathname.pwd
104
84
 
@@ -118,9 +98,54 @@ module CFoundry
118
98
  end
119
99
  end
120
100
 
101
+ # TODO: handle negation
102
+ def files_to_consider(path, exclusions)
103
+ entries = all_files(path)
104
+
105
+ to_exclude = exclusions.dup
106
+ until to_exclude.empty?
107
+ exclude = to_exclude.shift
108
+
109
+ entries.reject! do |entry|
110
+ is_dir = File.directory?(entry)
111
+ excluded = glob_matches?(entry, path, exclude)
112
+
113
+ if is_dir && excluded
114
+ # if a directory was excluded, exclude its contents
115
+ to_exclude.unshift(entry.sub(path + "/", "/") + "/**")
116
+ end
117
+
118
+ excluded
119
+ end
120
+ end
121
+
122
+ entries
123
+ end
124
+
125
+ def glob_matches?(file, path, pattern)
126
+ name = file.sub("#{path}/", "/")
127
+ flags = File::FNM_DOTMATCH
128
+
129
+ # when pattern ends with /, match only directories
130
+ if pattern.end_with?("/") && File.directory?(file)
131
+ name = "#{name}/"
132
+ end
133
+
134
+ case pattern
135
+ # when pattern contains /, do a pathname match
136
+ when /\/./
137
+ flags |= File::FNM_PATHNAME
138
+
139
+ # otherwise, match any file path
140
+ else
141
+ pattern = "**/#{pattern}"
142
+ end
143
+
144
+ File.fnmatch(pattern, name, flags)
145
+ end
146
+
121
147
  def find_sockets(path)
122
- files = Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
123
- files && files.select { |f| File.socket? f }
148
+ all_files(path).select { |f| File.socket? f }
124
149
  end
125
150
 
126
151
  def determine_resources(path)
@@ -150,14 +175,13 @@ module CFoundry
150
175
  # This ensures that directories containing empty directories
151
176
  # are also pruned.
152
177
  def prune_empty_directories(path)
153
- all_files = Dir["#{path}/**/{*,.*}"]
154
- all_files.reject! { |fn| fn =~ /\/\.+$/ }
178
+ all_files = all_files(path)
155
179
 
156
180
  directories = all_files.select { |x| File.directory?(x) }
157
181
  directories.sort! { |a, b| b.size <=> a.size }
158
182
 
159
183
  directories.each do |directory|
160
- entries = Dir.entries(directory) - %w{. ..}
184
+ entries = all_files(directory)
161
185
  FileUtils.rmdir(directory) if entries.empty?
162
186
  end
163
187
  end
@@ -166,7 +190,7 @@ module CFoundry
166
190
  fingerprints = []
167
191
  total_size = 0
168
192
 
169
- Dir.glob("#{path}/**/*", File::FNM_DOTMATCH) do |filename|
193
+ all_files(path).each do |filename|
170
194
  next if File.directory?(filename)
171
195
 
172
196
  size = File.size(filename)
@@ -182,5 +206,25 @@ module CFoundry
182
206
 
183
207
  [fingerprints, total_size]
184
208
  end
209
+
210
+ def all_files(path)
211
+ Dir.glob("#{path}/**/*", File::FNM_DOTMATCH).reject! do |fn|
212
+ fn =~ /\.$/
213
+ end
214
+ end
215
+
216
+ def copy_tree(files, path, to)
217
+ files.each do |file|
218
+ dest = file.sub("#{path}/", "#{to}/")
219
+
220
+ if File.directory?(file)
221
+ FileUtils.mkdir_p(dest)
222
+ else
223
+ destdir = File.dirname(dest)
224
+ FileUtils.mkdir_p(destdir)
225
+ FileUtils.cp(file, dest)
226
+ end
227
+ end
228
+ end
185
229
  end
186
230
  end
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.5.3.rc2".freeze
3
+ VERSION = "0.5.3.rc3".freeze
4
4
  end
@@ -95,12 +95,14 @@ describe CFoundry::UploadHelpers do
95
95
  subject
96
96
  end
97
97
 
98
- it 'does not include files and directories specified in the vmcignore (including glob patterns)' do
98
+ it 'does not include files and directories specified in the vmcignore' do
99
99
  mock_zip do |src, _|
100
100
  files = relative_glob(src)
101
- expect(files).not_to include "ignored_dir"
102
- expect(files).not_to include "ignored_file.txt"
103
- expect(files).not_to include "non_ignored_dir/ignored_file.txt" # glob pattern **/ignored_file.txt
101
+ expect(files).to match_array(%w[
102
+ .hidden_file .vmcignore non_ignored_dir ambiguous_ignored
103
+ non_ignored_dir/file_in_non_ignored_dir.txt non_ignored_file.txt
104
+ non_ignored_dir/toplevel_ignored.txt
105
+ ])
104
106
  end
105
107
  subject
106
108
  end
@@ -170,5 +172,23 @@ describe CFoundry::UploadHelpers do
170
172
  fake_model.upload(path)
171
173
  end
172
174
  end
175
+
176
+ context "when there is a symlink pointing outside of the root" do
177
+ let(:path) { "#{SPEC_ROOT}/fixtures/apps/with_external_symlink" }
178
+
179
+ it "blows up" do
180
+ expect {
181
+ fake_model.upload(path)
182
+ }.to raise_error(CFoundry::Error, /contains links.*that point outside/)
183
+ end
184
+
185
+ context "and it is vmcignored" do
186
+ let(:path) { "#{SPEC_ROOT}/fixtures/apps/with_ignored_external_symlink" }
187
+
188
+ it "ignores it" do
189
+ expect { fake_model.upload(path) }.to_not raise_error
190
+ end
191
+ end
192
+ end
173
193
  end
174
194
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1906723574
4
+ hash: 1230613173
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
9
  - 3
10
10
  - rc
11
- - 2
12
- version: 0.5.3.rc2
11
+ - 3
12
+ version: 0.5.3.rc3
13
13
  platform: ruby
14
14
  authors:
15
15
  - Cloud Foundry Team
@@ -18,10 +18,12 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2013-03-07 00:00:00 Z
21
+ date: 2013-03-08 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ name: multipart-post
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
25
27
  none: false
26
28
  requirements:
27
29
  - - ~>
@@ -31,12 +33,12 @@ dependencies:
31
33
  - 1
32
34
  - 1
33
35
  version: "1.1"
34
- prerelease: false
35
36
  type: :runtime
36
- name: multipart-post
37
- requirement: *id001
37
+ version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
39
+ name: multi_json
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
40
42
  none: false
41
43
  requirements:
42
44
  - - ~>
@@ -46,12 +48,12 @@ dependencies:
46
48
  - 1
47
49
  - 3
48
50
  version: "1.3"
49
- prerelease: false
50
51
  type: :runtime
51
- name: multi_json
52
- requirement: *id002
52
+ version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ name: rubyzip
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
55
57
  none: false
56
58
  requirements:
57
59
  - - ~>
@@ -61,12 +63,12 @@ dependencies:
61
63
  - 0
62
64
  - 9
63
65
  version: "0.9"
64
- prerelease: false
65
66
  type: :runtime
66
- name: rubyzip
67
- requirement: *id003
67
+ version_requirements: *id003
68
68
  - !ruby/object:Gem::Dependency
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
69
+ name: cf-uaa-lib
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
70
72
  none: false
71
73
  requirements:
72
74
  - - ~>
@@ -77,12 +79,12 @@ dependencies:
77
79
  - 3
78
80
  - 3
79
81
  version: 1.3.3
80
- prerelease: false
81
82
  type: :runtime
82
- name: cf-uaa-lib
83
- requirement: *id004
83
+ version_requirements: *id004
84
84
  - !ruby/object:Gem::Dependency
85
- version_requirements: &id005 !ruby/object:Gem::Requirement
85
+ name: rake
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
86
88
  none: false
87
89
  requirements:
88
90
  - - ~>
@@ -92,12 +94,12 @@ dependencies:
92
94
  - 0
93
95
  - 9
94
96
  version: "0.9"
95
- prerelease: false
96
97
  type: :development
97
- name: rake
98
- requirement: *id005
98
+ version_requirements: *id005
99
99
  - !ruby/object:Gem::Dependency
100
- version_requirements: &id006 !ruby/object:Gem::Requirement
100
+ name: rspec
101
+ prerelease: false
102
+ requirement: &id006 !ruby/object:Gem::Requirement
101
103
  none: false
102
104
  requirements:
103
105
  - - ~>
@@ -107,12 +109,12 @@ dependencies:
107
109
  - 2
108
110
  - 11
109
111
  version: "2.11"
110
- prerelease: false
111
112
  type: :development
112
- name: rspec
113
- requirement: *id006
113
+ version_requirements: *id006
114
114
  - !ruby/object:Gem::Dependency
115
- version_requirements: &id007 !ruby/object:Gem::Requirement
115
+ name: webmock
116
+ prerelease: false
117
+ requirement: &id007 !ruby/object:Gem::Requirement
116
118
  none: false
117
119
  requirements:
118
120
  - - ~>
@@ -122,12 +124,12 @@ dependencies:
122
124
  - 1
123
125
  - 9
124
126
  version: "1.9"
125
- prerelease: false
126
127
  type: :development
127
- name: webmock
128
- requirement: *id007
128
+ version_requirements: *id007
129
129
  - !ruby/object:Gem::Dependency
130
- version_requirements: &id008 !ruby/object:Gem::Requirement
130
+ name: rr
131
+ prerelease: false
132
+ requirement: &id008 !ruby/object:Gem::Requirement
131
133
  none: false
132
134
  requirements:
133
135
  - - ~>
@@ -137,12 +139,12 @@ dependencies:
137
139
  - 1
138
140
  - 0
139
141
  version: "1.0"
140
- prerelease: false
141
142
  type: :development
142
- name: rr
143
- requirement: *id008
143
+ version_requirements: *id008
144
144
  - !ruby/object:Gem::Dependency
145
- version_requirements: &id009 !ruby/object:Gem::Requirement
145
+ name: gem-release
146
+ prerelease: false
147
+ requirement: &id009 !ruby/object:Gem::Requirement
146
148
  none: false
147
149
  requirements:
148
150
  - - ">="
@@ -151,12 +153,12 @@ dependencies:
151
153
  segments:
152
154
  - 0
153
155
  version: "0"
154
- prerelease: false
155
156
  type: :development
156
- name: gem-release
157
- requirement: *id009
157
+ version_requirements: *id009
158
158
  - !ruby/object:Gem::Dependency
159
- version_requirements: &id010 !ruby/object:Gem::Requirement
159
+ name: timecop
160
+ prerelease: false
161
+ requirement: &id010 !ruby/object:Gem::Requirement
160
162
  none: false
161
163
  requirements:
162
164
  - - ">="
@@ -165,10 +167,8 @@ dependencies:
165
167
  segments:
166
168
  - 0
167
169
  version: "0"
168
- prerelease: false
169
170
  type: :development
170
- name: timecop
171
- requirement: *id010
171
+ version_requirements: *id010
172
172
  description:
173
173
  email:
174
174
  - vcap-dev@googlegroups.com
@@ -284,13 +284,18 @@ files:
284
284
  - spec/fakes/space_fake.rb
285
285
  - spec/fakes/user_fake.rb
286
286
  - spec/fixtures/apps/with_dotfiles/xyz
287
+ - spec/fixtures/apps/with_external_symlink/foo
288
+ - spec/fixtures/apps/with_ignored_external_symlink/foo
287
289
  - spec/fixtures/apps/with_nested_directories/foo/bar/baz/fizz
288
290
  - spec/fixtures/apps/with_nested_directories/xyz
291
+ - spec/fixtures/apps/with_vmcignore/ambiguous_ignored
289
292
  - spec/fixtures/apps/with_vmcignore/ignored_dir/file_in_ignored_dir.txt
290
293
  - spec/fixtures/apps/with_vmcignore/ignored_file.txt
291
294
  - spec/fixtures/apps/with_vmcignore/non_ignored_dir/file_in_non_ignored_dir.txt
292
295
  - spec/fixtures/apps/with_vmcignore/non_ignored_dir/ignored_file.txt
296
+ - spec/fixtures/apps/with_vmcignore/non_ignored_dir/toplevel_ignored.txt
293
297
  - spec/fixtures/apps/with_vmcignore/non_ignored_file.txt
298
+ - spec/fixtures/apps/with_vmcignore/toplevel_ignored.txt
294
299
  - spec/fixtures/empty_file
295
300
  - spec/fixtures/fake_cc_application.json
296
301
  - spec/fixtures/fake_cc_application_summary.json
@@ -405,13 +410,18 @@ test_files:
405
410
  - spec/fakes/space_fake.rb
406
411
  - spec/fakes/user_fake.rb
407
412
  - spec/fixtures/apps/with_dotfiles/xyz
413
+ - spec/fixtures/apps/with_external_symlink/foo
414
+ - spec/fixtures/apps/with_ignored_external_symlink/foo
408
415
  - spec/fixtures/apps/with_nested_directories/foo/bar/baz/fizz
409
416
  - spec/fixtures/apps/with_nested_directories/xyz
417
+ - spec/fixtures/apps/with_vmcignore/ambiguous_ignored
410
418
  - spec/fixtures/apps/with_vmcignore/ignored_dir/file_in_ignored_dir.txt
411
419
  - spec/fixtures/apps/with_vmcignore/ignored_file.txt
412
420
  - spec/fixtures/apps/with_vmcignore/non_ignored_dir/file_in_non_ignored_dir.txt
413
421
  - spec/fixtures/apps/with_vmcignore/non_ignored_dir/ignored_file.txt
422
+ - spec/fixtures/apps/with_vmcignore/non_ignored_dir/toplevel_ignored.txt
414
423
  - spec/fixtures/apps/with_vmcignore/non_ignored_file.txt
424
+ - spec/fixtures/apps/with_vmcignore/toplevel_ignored.txt
415
425
  - spec/fixtures/empty_file
416
426
  - spec/fixtures/fake_cc_application.json
417
427
  - spec/fixtures/fake_cc_application_summary.json