7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/backofen/prototype.rb', line 7
def run(path)
repo = Git.open(path)
url = repo.remotes.first.url
puts "Cloning from #{url}.."
d = Dir.mktmpdir
tmp_repo = Git.clone(url, 'tmp_clone', :path => d)
tmp_repo_path = tmp_repo.dir.path
puts "Cloned to: #{tmp_repo_path}"
patch_working_file_path = File.join(tmp_repo_path, 'patch_working')
patch_index_file_path = File.join(tmp_repo_path, 'patch_index')
puts "Creating patches.."
%x(cd #{path} && git diff -p > patch_working)
%x(cd #{path} && git diff --cached -p > patch_index)
%x(mv #{path}/patch_working #{patch_working_file_path})
%x(mv #{path}/patch_index #{patch_index_file_path})
puts "Applying patches.."
%x(cd #{tmp_repo_path} && git apply patch_working)
%x(cd #{tmp_repo_path} && git apply patch_index)
if File.exist?(File.join(path, 'config', 'database.yml'))
puts "Found a Rails application.."
%x(cp #{path}/config/database.yml #{tmp_repo_path}/config/)
end
system("cd #{tmp_repo_path} && rake db:migrate && rake spec && rake cucumber")
puts $?.exitstatus == 0 ? 'Integration succeeded' : 'Integration failed'
exit($?.exitstatus)
end
|