right_scraper 3.2.6 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/right_scraper.rb +16 -34
- data/lib/right_scraper/builders.rb +32 -0
- data/lib/right_scraper/builders/base.rb +19 -20
- data/lib/right_scraper/builders/filesystem.rb +8 -6
- data/lib/right_scraper/builders/union.rb +4 -1
- data/lib/right_scraper/loggers.rb +31 -0
- data/lib/right_scraper/loggers/base.rb +113 -0
- data/lib/right_scraper/loggers/default.rb +98 -0
- data/lib/right_scraper/{scraper.rb → main.rb} +53 -9
- data/lib/right_scraper/processes.rb +33 -0
- data/lib/right_scraper/processes/shell.rb +227 -0
- data/lib/right_scraper/processes/{ssh.rb → ssh_agent.rb} +4 -0
- data/lib/right_scraper/processes/svn_client.rb +117 -0
- data/lib/right_scraper/processes/warden.rb +358 -0
- data/lib/right_scraper/registered_base.rb +154 -0
- data/lib/right_scraper/repositories.rb +33 -0
- data/lib/right_scraper/repositories/base.rb +271 -232
- data/lib/right_scraper/repositories/download.rb +8 -6
- data/lib/right_scraper/repositories/git.rb +8 -9
- data/lib/right_scraper/repositories/svn.rb +8 -8
- data/lib/right_scraper/resources.rb +32 -0
- data/lib/right_scraper/resources/base.rb +5 -1
- data/lib/right_scraper/resources/cookbook.rb +34 -27
- data/lib/right_scraper/resources/workflow.rb +27 -28
- data/lib/right_scraper/retrievers.rb +34 -0
- data/lib/right_scraper/retrievers/base.rb +80 -84
- data/lib/right_scraper/retrievers/checkout_base.rb +178 -0
- data/lib/right_scraper/retrievers/download.rb +125 -117
- data/lib/right_scraper/retrievers/git.rb +377 -223
- data/lib/right_scraper/retrievers/svn.rb +102 -62
- data/lib/right_scraper/scanners.rb +37 -0
- data/lib/right_scraper/scanners/base.rb +77 -80
- data/lib/right_scraper/scanners/cookbook_manifest.rb +31 -30
- data/lib/right_scraper/scanners/cookbook_metadata.rb +380 -35
- data/lib/right_scraper/scanners/cookbook_s3_upload.rb +56 -53
- data/lib/right_scraper/scanners/union.rb +61 -58
- data/lib/right_scraper/scanners/workflow_manifest.rb +55 -54
- data/lib/right_scraper/scanners/workflow_metadata.rb +41 -39
- data/lib/right_scraper/scanners/workflow_s3_upload.rb +59 -55
- data/lib/right_scraper/scrapers.rb +32 -0
- data/lib/right_scraper/scrapers/base.rb +217 -205
- data/lib/right_scraper/scrapers/cookbook.rb +42 -40
- data/lib/right_scraper/scrapers/workflow.rb +57 -58
- data/lib/right_scraper/version.rb +3 -0
- data/right_scraper.gemspec +12 -16
- metadata +57 -163
- data/Gemfile +0 -15
- data/Rakefile +0 -89
- data/lib/right_scraper/logger.rb +0 -107
- data/lib/right_scraper/loggers/noisy.rb +0 -85
- data/lib/right_scraper/repositories/mock.rb +0 -70
- data/lib/right_scraper/retrievers/checkout.rb +0 -79
- data/lib/right_scraper/scraper_logger.rb +0 -66
- data/lib/right_scraper/svn_client.rb +0 -164
- data/right_scraper.rconf +0 -13
- data/spec/builder_spec.rb +0 -50
- data/spec/cookbook_helper.rb +0 -73
- data/spec/cookbook_manifest_spec.rb +0 -93
- data/spec/cookbook_s3_upload_spec.rb +0 -159
- data/spec/download/download_retriever_spec.rb +0 -118
- data/spec/download/download_retriever_spec_helper.rb +0 -72
- data/spec/download/download_spec.rb +0 -128
- data/spec/download/multi_dir_spec.rb +0 -106
- data/spec/download/multi_dir_spec_helper.rb +0 -40
- data/spec/git/cookbook_spec.rb +0 -165
- data/spec/git/demokey +0 -27
- data/spec/git/demokey.pub +0 -1
- data/spec/git/password_key +0 -30
- data/spec/git/password_key.pub +0 -1
- data/spec/git/repository_spec.rb +0 -110
- data/spec/git/retriever_spec.rb +0 -553
- data/spec/git/retriever_spec_helper.rb +0 -112
- data/spec/git/scraper_spec.rb +0 -151
- data/spec/git/ssh_spec.rb +0 -174
- data/spec/git/url_spec.rb +0 -103
- data/spec/logger_spec.rb +0 -185
- data/spec/repository_spec.rb +0 -111
- data/spec/retriever_spec_helper.rb +0 -146
- data/spec/scanner_spec.rb +0 -61
- data/spec/scraper_helper.rb +0 -88
- data/spec/scraper_spec.rb +0 -147
- data/spec/spec_helper.rb +0 -185
- data/spec/svn/cookbook_spec.rb +0 -96
- data/spec/svn/multi_svn_spec.rb +0 -64
- data/spec/svn/multi_svn_spec_helper.rb +0 -40
- data/spec/svn/repository_spec.rb +0 -72
- data/spec/svn/retriever_spec.rb +0 -266
- data/spec/svn/scraper_spec.rb +0 -90
- data/spec/svn/svn_retriever_spec_helper.rb +0 -90
- data/spec/svn/url_spec.rb +0 -47
- data/spec/url_spec.rb +0 -164
data/spec/git/retriever_spec.rb
DELETED
@@ -1,553 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright: Copyright (c) 2010-2011 RightScale, Inc.
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# 'Software'), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'retriever_spec_helper'))
|
25
|
-
require 'set'
|
26
|
-
|
27
|
-
describe RightScraper::Retrievers::Git do
|
28
|
-
include RightScraper::SpecHelpers::DevelopmentModeEnvironment
|
29
|
-
|
30
|
-
include RightScraper::ScraperHelper
|
31
|
-
|
32
|
-
def secondary_cookbook(where)
|
33
|
-
FileUtils.mkdir_p(where)
|
34
|
-
@helper.create_cookbook(where, @helper.repo_content)
|
35
|
-
end
|
36
|
-
|
37
|
-
def secondary_workflow(where, name=nil, definition=nil, metadata=nil)
|
38
|
-
FileUtils.mkdir_p(where)
|
39
|
-
@helper.create_workflow(where, name || 'workflow',
|
40
|
-
definition || "sequence\n a\n b",
|
41
|
-
metadata || {"random" => 42 })
|
42
|
-
end
|
43
|
-
|
44
|
-
def get_scraper(repo, basedir)
|
45
|
-
@retriever = @retriever_class.new(repo,
|
46
|
-
:basedir => basedir,
|
47
|
-
:max_bytes => 1024**2,
|
48
|
-
:max_seconds => 20)
|
49
|
-
@retriever.retrieve
|
50
|
-
@scraper = RightScraper::Scrapers::Base.scraper(:repo_dir => @retriever.repo_dir,
|
51
|
-
:kind => :cookbook,
|
52
|
-
:repository => @retriever.repository,
|
53
|
-
:ignorable_paths => @retriever.ignorable_paths)
|
54
|
-
end
|
55
|
-
|
56
|
-
before(:all) do
|
57
|
-
@ignore = ['.git']
|
58
|
-
@retriever_class = RightScraper::Retrievers::Git
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'given a git repository' do
|
62
|
-
before(:each) do
|
63
|
-
@helper = RightScraper::GitRetrieverSpecHelper.new
|
64
|
-
@repo = RightScraper::Repositories::Base.from_hash(
|
65
|
-
:display_name => 'test repo',
|
66
|
-
:repo_type => :git,
|
67
|
-
:url => @helper.repo_path)
|
68
|
-
end
|
69
|
-
|
70
|
-
after(:each) do
|
71
|
-
@helper.close unless @helper.nil?
|
72
|
-
@helper = nil
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'of workflows' do
|
76
|
-
|
77
|
-
before(:each) do
|
78
|
-
@helper.setup_workflows
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'with one workflow' do
|
82
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
83
|
-
include RightScraper::SpecHelpers::WorkflowScraping
|
84
|
-
|
85
|
-
it 'should scrape the master branch' do
|
86
|
-
check_resource @scraper.next_resource,
|
87
|
-
:position => 'workflow.def',
|
88
|
-
:metadata => {},
|
89
|
-
:manifest => {"workflow.def"=>"15ce480ea6c94b51056e028b0e0bd7da8024d924",
|
90
|
-
"workflow.meta"=>"5f36b2ea290645ee34d943220a14b54ee5ea5be5"}
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'should only see one workflow' do
|
94
|
-
@scraper.next_resource.should_not == nil
|
95
|
-
@scraper.next_resource.should == nil
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should record the head SHA' do
|
99
|
-
tag = @scraper.next_resource.repository.tag
|
100
|
-
tag.should_not == "master"
|
101
|
-
tag.should =~ /^[A-Fa-f0-9]+$/
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context 'with a subworkflow' do
|
106
|
-
before(:each) do
|
107
|
-
subdir = File.join(@helper.repo_path, "workflow")
|
108
|
-
secondary_workflow(subdir)
|
109
|
-
@helper.commit_content("subworkflow added")
|
110
|
-
end
|
111
|
-
|
112
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
113
|
-
include RightScraper::SpecHelpers::WorkflowScraping
|
114
|
-
|
115
|
-
it 'should see two workflows' do
|
116
|
-
@scraper.next_resource.should_not == nil
|
117
|
-
@scraper.next_resource.should_not == nil
|
118
|
-
@scraper.next_resource.should == nil
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'should have the subworkflow in the manifest' do
|
122
|
-
workflow = @scraper.next_resource
|
123
|
-
workflow = @scraper.next_resource
|
124
|
-
workflow.manifest["workflow.def"].should == "e687ad52d8fba8010a255e3c2a9e891264a24910"
|
125
|
-
workflow.manifest["workflow.meta"].should == "58060413e90f84add5b2dace3ba7e30d2689336f"
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context 'with multiple workflows' do
|
130
|
-
before(:each) do
|
131
|
-
FileUtils.rm(File.join(@helper.repo_path, "workflow.meta"))
|
132
|
-
@workflow_places = [File.join(@helper.repo_path, "workflows", "first"),
|
133
|
-
File.join(@helper.repo_path, "workflows", "second"),
|
134
|
-
File.join(@helper.repo_path, "other_random_place")]
|
135
|
-
@workflow_places.each {|place| secondary_workflow(place)}
|
136
|
-
@helper.commit_content("secondary workflows added")
|
137
|
-
end
|
138
|
-
|
139
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
140
|
-
include RightScraper::SpecHelpers::WorkflowScraping
|
141
|
-
|
142
|
-
it 'should scrape' do
|
143
|
-
scraped = []
|
144
|
-
while scrape = @scraper.next_resource
|
145
|
-
place = (@workflow_places - scraped).detect {|place| File.join(@helper.repo_path, scrape.pos) == place}
|
146
|
-
scraped << place
|
147
|
-
check_resource scrape, :position => scrape.pos,
|
148
|
-
:metadata => {"random" => 42 },
|
149
|
-
:manifest => {"workflow.def" =>"e687ad52d8fba8010a255e3c2a9e891264a24910",
|
150
|
-
"workflow.meta"=>"58060413e90f84add5b2dace3ba7e30d2689336f"}
|
151
|
-
end
|
152
|
-
scraped.should have(@workflow_places.size).repositories
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context 'with two-level deep workflows' do
|
157
|
-
before(:each) do
|
158
|
-
@workflow_places = [File.join(@helper.repo_path, "workflows", "first"),
|
159
|
-
File.join(@helper.repo_path, "workflows", "some_dir", "some_subdir", "second"),
|
160
|
-
File.join(@helper.repo_path, "workflows", "some_dir", "some_subdir", "third")]
|
161
|
-
@workflow_places.each {|place| secondary_workflow(place)}
|
162
|
-
@helper.commit_content("secondary workflows added")
|
163
|
-
end
|
164
|
-
|
165
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
166
|
-
include RightScraper::SpecHelpers::WorkflowScraping
|
167
|
-
|
168
|
-
it 'should scrape' do
|
169
|
-
@scraper.scrape
|
170
|
-
@scraper.resources.each do |res|
|
171
|
-
res.metadata_path.should_not be_nil
|
172
|
-
res.definition_path.should_not be_nil
|
173
|
-
end
|
174
|
-
@scraper.resources.size.should == @workflow_places.size + 1 # One in the root repo_path
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
context 'of cookbooks' do
|
181
|
-
|
182
|
-
before(:each) do
|
183
|
-
@helper.setup_cookbooks
|
184
|
-
end
|
185
|
-
|
186
|
-
context 'with one cookbook' do
|
187
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
188
|
-
include RightScraper::SpecHelpers::CookbookScraping
|
189
|
-
|
190
|
-
it 'should scrape the master branch' do
|
191
|
-
check_resource @scraper.next_resource
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'should only see one cookbook' do
|
195
|
-
@scraper.next_resource.should_not == nil
|
196
|
-
@scraper.next_resource.should == nil
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'should record the head SHA' do
|
200
|
-
tag = @scraper.next_resource.repository.tag
|
201
|
-
tag.should_not == "master"
|
202
|
-
tag.should =~ /^[A-Fa-f0-9]+$/
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
context 'with a subcookbook' do
|
207
|
-
before(:each) do
|
208
|
-
@subdir = File.join(@helper.repo_path, "cookbook")
|
209
|
-
secondary_cookbook(@subdir)
|
210
|
-
@helper.commit_content("subcookbook added")
|
211
|
-
end
|
212
|
-
|
213
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
214
|
-
include RightScraper::SpecHelpers::CookbookScraping
|
215
|
-
|
216
|
-
it 'should still see only one cookbook' do
|
217
|
-
@scraper.next_resource.should_not == nil
|
218
|
-
@scraper.next_resource.should == nil
|
219
|
-
end
|
220
|
-
|
221
|
-
it 'should have the subcookbook in the manifest' do
|
222
|
-
cookbook = @scraper.next_resource
|
223
|
-
contents = ::File.read(::File.join(@subdir, "metadata.json"))
|
224
|
-
cookbook.manifest["cookbook/metadata.json"].should == ::Digest::MD5.hexdigest(contents)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
context 'with multiple cookbooks' do
|
229
|
-
before(:each) do
|
230
|
-
FileUtils.rm(File.join(@helper.repo_path, "metadata.json"))
|
231
|
-
@cookbook_places = [File.join(@helper.repo_path, "cookbooks", "first"),
|
232
|
-
File.join(@helper.repo_path, "cookbooks", "second"),
|
233
|
-
File.join(@helper.repo_path, "other_random_place")]
|
234
|
-
@cookbook_places.each {|place| secondary_cookbook(place)}
|
235
|
-
@helper.commit_content("secondary cookbooks added")
|
236
|
-
end
|
237
|
-
|
238
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
239
|
-
include RightScraper::SpecHelpers::CookbookScraping
|
240
|
-
|
241
|
-
it 'should scrape' do
|
242
|
-
scraped = []
|
243
|
-
while scrape = @scraper.next_resource
|
244
|
-
place = (@cookbook_places - scraped).detect {|place| File.join(@helper.repo_path, scrape.pos) == place}
|
245
|
-
scraped << place
|
246
|
-
check_resource scrape, :position => scrape.pos
|
247
|
-
end
|
248
|
-
scraped.should have(@cookbook_places.size).repositories
|
249
|
-
end
|
250
|
-
|
251
|
-
end
|
252
|
-
|
253
|
-
context 'and a branch' do
|
254
|
-
before(:each) do
|
255
|
-
@helper.setup_branch('test_branch', @helper.branch_content)
|
256
|
-
@repo = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
|
257
|
-
:repo_type => :git,
|
258
|
-
:url => @helper.repo_path,
|
259
|
-
:tag => 'test_branch')
|
260
|
-
end
|
261
|
-
|
262
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
263
|
-
include RightScraper::SpecHelpers::CookbookScraping
|
264
|
-
|
265
|
-
it 'should scrape a branch' do
|
266
|
-
check_resource @scraper.next_resource
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
|
-
context 'and a branch and a tag that are named the same' do
|
271
|
-
before(:each) do
|
272
|
-
@helper.setup_branch('test_branch')
|
273
|
-
@helper.setup_tag('test_branch')
|
274
|
-
@repo = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
|
275
|
-
:repo_type => :git,
|
276
|
-
:url => @helper.repo_path,
|
277
|
-
:tag => 'test_branch')
|
278
|
-
end
|
279
|
-
|
280
|
-
it 'should fail to scrape' do
|
281
|
-
lambda {
|
282
|
-
@scraper = get_scraper(@repo, @helper.scraper_path)
|
283
|
-
@scraper.next_resource
|
284
|
-
@scraper.close
|
285
|
-
}.should raise_exception(/Ambiguous reference/)
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
context 'and a tag' do
|
290
|
-
before(:each) do
|
291
|
-
@helper.setup_tag('test_tag')
|
292
|
-
@repo = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
|
293
|
-
:repo_type => :git,
|
294
|
-
:url => @helper.repo_path,
|
295
|
-
:tag => 'test_tag')
|
296
|
-
end
|
297
|
-
|
298
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
299
|
-
include RightScraper::SpecHelpers::CookbookScraping
|
300
|
-
|
301
|
-
it 'should scrape a tag' do
|
302
|
-
check_resource @scraper.next_resource
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
context 'and a sha ref' do
|
307
|
-
before(:each) do
|
308
|
-
@oldmetadata = @helper.repo_content
|
309
|
-
@helper.create_file_layout(@helper.repo_path, @helper.branch_content)
|
310
|
-
@helper.commit_content
|
311
|
-
@repo = RightScraper::Repositories::Base.from_hash(:display_name => 'test repo',
|
312
|
-
:repo_type => :git,
|
313
|
-
:url => @helper.repo_path,
|
314
|
-
:tag => @helper.commit_id(1))
|
315
|
-
end
|
316
|
-
|
317
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
318
|
-
include RightScraper::SpecHelpers::CookbookScraping
|
319
|
-
|
320
|
-
it 'should scrape a sha' do
|
321
|
-
check_resource @scraper.next_resource, :metadata => @oldmetadata, :rootdir => @scraper.send(:repo_dir)
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
context 'and an incremental scraper' do
|
326
|
-
|
327
|
-
def reset_scraper
|
328
|
-
@olddir = @scraper.send(:repo_dir)
|
329
|
-
@scraper.close
|
330
|
-
@scraper = get_scraper(@repo, @helper.scraper_path)
|
331
|
-
end
|
332
|
-
|
333
|
-
before(:each) do
|
334
|
-
@scraper = get_scraper(@repo, @helper.scraper_path)
|
335
|
-
end
|
336
|
-
|
337
|
-
after(:each) do
|
338
|
-
@scraper.close if @scraper
|
339
|
-
@scraper = nil
|
340
|
-
end
|
341
|
-
|
342
|
-
it 'the scraper should store intermediate versions where we expect' do
|
343
|
-
@scraper.send(:repo_dir).should begin_with @helper.scraper_path
|
344
|
-
end
|
345
|
-
|
346
|
-
it 'the scraper should scrape' do
|
347
|
-
check_resource @scraper.next_resource
|
348
|
-
end
|
349
|
-
|
350
|
-
it 'the scraper should only see one cookbook' do
|
351
|
-
@scraper.next_resource.should_not == nil
|
352
|
-
@scraper.next_resource.should == nil
|
353
|
-
end
|
354
|
-
|
355
|
-
context 'after the scraper runs once' do
|
356
|
-
before(:each) do
|
357
|
-
check_resource @scraper.next_resource
|
358
|
-
end
|
359
|
-
|
360
|
-
context 'and a branch is made on the master repo' do
|
361
|
-
before(:each) do
|
362
|
-
@helper.setup_branch("foo")
|
363
|
-
@helper.create_file_layout(@helper.repo_path, ['fredbarney'])
|
364
|
-
@helper.commit_content("branch")
|
365
|
-
@helper.setup_branch("master")
|
366
|
-
end
|
367
|
-
|
368
|
-
it 'should be able to check the new branch out' do
|
369
|
-
@repo.tag = "foo"
|
370
|
-
reset_scraper
|
371
|
-
@scraper.next_resource
|
372
|
-
File.exists?(File.join(@retriever.repo_dir, 'fredbarney')).should be_true
|
373
|
-
end
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
context 'when a change is made to the master repo' do
|
378
|
-
before(:each) do
|
379
|
-
@helper.create_file_layout(@helper.repo_path, @helper.branch_content)
|
380
|
-
@helper.commit_content("change to master")
|
381
|
-
@helper.create_file_layout(@helper.repo_path, ['frob'])
|
382
|
-
@helper.commit_content("alpha")
|
383
|
-
@helper.create_file_layout(@helper.repo_path, ['botz'])
|
384
|
-
@helper.commit_content("beta")
|
385
|
-
@helper.create_file_layout(@helper.repo_path, ['fred'])
|
386
|
-
@helper.commit_content("delta")
|
387
|
-
@helper.create_file_layout(@helper.repo_path, ['barney'])
|
388
|
-
@helper.commit_content("gamma")
|
389
|
-
end
|
390
|
-
|
391
|
-
context 'when a branch is made on the master repo' do
|
392
|
-
before(:each) do
|
393
|
-
@helper.setup_branch("foo")
|
394
|
-
@helper.create_file_layout(@helper.repo_path, ['fredbarney'])
|
395
|
-
@helper.commit_content("branch")
|
396
|
-
@helper.setup_branch("master")
|
397
|
-
end
|
398
|
-
|
399
|
-
context 'and a scrape happens' do
|
400
|
-
before(:each) do
|
401
|
-
reset_scraper
|
402
|
-
@scraper.next_resource
|
403
|
-
end
|
404
|
-
|
405
|
-
context 'and the branch is deleted' do
|
406
|
-
before(:each) do
|
407
|
-
@helper.delete_branch("foo")
|
408
|
-
end
|
409
|
-
|
410
|
-
context 'a new scraper' do
|
411
|
-
before(:each) do
|
412
|
-
reset_scraper
|
413
|
-
end
|
414
|
-
|
415
|
-
it 'should not see any such branch exists' do
|
416
|
-
@helper.branch?("foo").should be_false
|
417
|
-
end
|
418
|
-
end
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
context 'a new scraper' do
|
423
|
-
before(:each) do
|
424
|
-
reset_scraper
|
425
|
-
end
|
426
|
-
|
427
|
-
it 'should not see the new change' do
|
428
|
-
File.exists?(File.join(@olddir, 'fredbarney')).should be_false
|
429
|
-
end
|
430
|
-
|
431
|
-
it 'should note that the branch exists' do
|
432
|
-
@helper.branch?("foo").should be_true
|
433
|
-
end
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
|
-
context 'a new scraper' do
|
438
|
-
before(:each) do
|
439
|
-
reset_scraper
|
440
|
-
end
|
441
|
-
|
442
|
-
context 'when an incompatible change is made to the master repo' do
|
443
|
-
before(:each) do
|
444
|
-
@scraper.next_resource
|
445
|
-
end
|
446
|
-
|
447
|
-
before(:each) do
|
448
|
-
@helper.create_file_layout(@helper.repo_path, [{'other_branch_folder' => ['file7']}])
|
449
|
-
@helper.commit_content("2nd change to master")
|
450
|
-
@helper.force_rebase('master^', 'master^^^^^')
|
451
|
-
end
|
452
|
-
|
453
|
-
context 'a new scraper' do
|
454
|
-
before(:each) do
|
455
|
-
reset_scraper
|
456
|
-
end
|
457
|
-
|
458
|
-
it 'should use the same directory for files' do
|
459
|
-
@olddir.should == @scraper.send(:repo_dir)
|
460
|
-
end
|
461
|
-
|
462
|
-
it 'should see the new change' do
|
463
|
-
File.exists?(File.join(@olddir, 'other_branch_folder', 'file7')).should be_true
|
464
|
-
end
|
465
|
-
|
466
|
-
it 'should not see the middle change' do
|
467
|
-
File.exists?(File.join(@olddir, 'frob')).should_not be_true
|
468
|
-
end
|
469
|
-
end
|
470
|
-
end
|
471
|
-
|
472
|
-
it 'should use the same directory for files' do
|
473
|
-
@olddir.should == @scraper.send(:repo_dir)
|
474
|
-
end
|
475
|
-
|
476
|
-
it 'should see the new change' do
|
477
|
-
File.exists?(File.join(@olddir, 'branch_folder', 'bfile1')).should be_true
|
478
|
-
end
|
479
|
-
end
|
480
|
-
|
481
|
-
context 'with tag being an empty string' do
|
482
|
-
before(:each) do
|
483
|
-
@repo.tag = ""
|
484
|
-
end
|
485
|
-
|
486
|
-
before(:each) do
|
487
|
-
reset_scraper
|
488
|
-
end
|
489
|
-
|
490
|
-
it 'should use the same directory for files' do
|
491
|
-
@olddir.should == @scraper.send(:repo_dir)
|
492
|
-
end
|
493
|
-
|
494
|
-
it 'should see the new change' do
|
495
|
-
File.exists?(File.join(@olddir, 'branch_folder', 'bfile1')).should be_true
|
496
|
-
end
|
497
|
-
end
|
498
|
-
end
|
499
|
-
end
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
context 'given a remote git repository requiring a credential' do
|
504
|
-
before(:each) do
|
505
|
-
@helper = RightScraper::GitRetrieverSpecHelper.new
|
506
|
-
credential_file = File.expand_path(File.join(File.dirname(__FILE__), 'demokey'))
|
507
|
-
credential = File.open(credential_file) { |f| f.read }
|
508
|
-
@repo = RightScraper::Repositories::Base.from_hash(
|
509
|
-
:display_name => 'test repo',
|
510
|
-
:repo_type => :git,
|
511
|
-
:url => 'git@github.com:xeger/cookbooks_test_fixture.git',
|
512
|
-
:first_credential => credential)
|
513
|
-
@helper.setup_cookbooks
|
514
|
-
end
|
515
|
-
|
516
|
-
after(:each) do
|
517
|
-
@helper.close unless @helper.nil?
|
518
|
-
@helper = nil
|
519
|
-
end
|
520
|
-
|
521
|
-
include RightScraper::SpecHelpers::FromScratchScraping
|
522
|
-
include RightScraper::SpecHelpers::CookbookScraping
|
523
|
-
|
524
|
-
it 'should see a cookbook' do
|
525
|
-
pending "Don't annoy GitHub unless ANNOY_GITHUB is set" unless ENV['ANNOY_GITHUB']
|
526
|
-
@scraper.next_resource.should_not be_nil
|
527
|
-
end
|
528
|
-
|
529
|
-
context :without_host_key_checking do
|
530
|
-
before(:each) do
|
531
|
-
@retriever = RightScraper::Retrievers::Git.new(@repo, :basedir=>@helper.scraper_path)
|
532
|
-
end
|
533
|
-
|
534
|
-
|
535
|
-
it 'should override the git-SSH command' do
|
536
|
-
ENV['GIT_SSH'] = nil
|
537
|
-
@retriever.without_host_key_checking do
|
538
|
-
ENV['GIT_SSH'].should =~ /ssh/
|
539
|
-
# Run the git-ssh command, make sure it invokes the SSH client
|
540
|
-
`#{ENV['GIT_SSH']} -V 2>&1`.should =~ /OpenSSH_[0-9]+\.[0-9]+/
|
541
|
-
end
|
542
|
-
end
|
543
|
-
|
544
|
-
it 'should clean up after itself' do
|
545
|
-
ENV['GIT_SSH'] = 'banana'
|
546
|
-
@retriever.without_host_key_checking do
|
547
|
-
ENV['GIT_SSH'].should =~ /ssh/
|
548
|
-
end
|
549
|
-
ENV['GIT_SSH'].should == 'banana'
|
550
|
-
end
|
551
|
-
end
|
552
|
-
end
|
553
|
-
end
|