ext 1.0.3 → 1.0.4
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/CHANGELOG +7 -0
- data/README +2 -0
- data/Rakefile +1 -74
- data/bin/ext +0 -0
- data/lib/externals/ext.rb +25 -9
- data/lib/externals/extensions/file_utils.rb +40 -0
- data/lib/externals/extensions/string.rb +1 -1
- data/lib/externals/project.rb +3 -0
- data/lib/externals/scms/git_project.rb +3 -4
- data/lib/externals/scms/svn_project.rb +10 -12
- data/lib/externals/test/basic_git_repository.rb +41 -0
- data/lib/externals/test/engines.rb +11 -0
- data/lib/externals/test/engines_with_branch1.rb +36 -0
- data/lib/externals/test/fake_rails_repository.rb +112 -0
- data/lib/externals/test/git_repository_from_internet.rb +19 -0
- data/lib/externals/test/modules_svn_branches_repository.rb +72 -0
- data/lib/externals/test/modules_svn_repository.rb +41 -0
- data/lib/externals/test/rails_app_git_branches.rb +100 -0
- data/lib/externals/test/rails_app_git_repository.rb +55 -0
- data/lib/externals/test/rails_app_svn_branches.rb +132 -0
- data/lib/externals/test/rails_app_svn_repository.rb +106 -0
- data/lib/externals/test/rails_app_unmanaged.rb +25 -0
- data/lib/externals/test/repository.rb +188 -0
- data/lib/externals/test/svn_repository_from_dump.rb +27 -0
- data/lib/externals/test/svn_repository_helper.rb +10 -0
- data/lib/externals/test_case.rb +16 -307
- data/test/setup/empty_plugin.svn.gz +0 -0
- data/test/setup/foreign_key_migrations.svn.gz +0 -0
- data/test/setup/redhillonrails_core.svn.gz +0 -0
- data/test/test_checkout_git.rb +16 -25
- data/test/test_checkout_with_subprojects_git.rb +109 -193
- data/test/test_checkout_with_subprojects_svn.rb +239 -294
- data/test/test_file_utils_extensions.rb +29 -0
- data/test/test_freeze_to_revision.rb +46 -85
- data/test/test_git_project_extract_name.rb +10 -8
- data/test/test_init_git.rb +19 -29
- data/test/test_projects.rb +87 -93
- data/test/test_rails_detection.rb +12 -17
- data/test/test_string_extensions.rb +32 -30
- data/test/test_svn_branches.rb +227 -383
- data/test/test_touch_emptydirs.rb +39 -34
- data/test/test_version.rb +18 -16
- metadata +47 -23
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'externals/test/repository'
|
2
|
+
require 'externals/test/git_repository_from_internet'
|
3
|
+
require 'externals/test/svn_repository_from_dump'
|
4
|
+
require 'externals/test/svn_repository_helper'
|
5
|
+
require 'externals/test/fake_rails_repository'
|
6
|
+
require 'externals/test/modules_svn_repository'
|
7
|
+
require 'externals/test/rails_app_unmanaged'
|
8
|
+
require 'externals/test/engines'
|
9
|
+
|
10
|
+
module Externals
|
11
|
+
module Test
|
12
|
+
class RailsAppSvnRepository < Repository
|
13
|
+
include SvnRepositoryHelper
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
super "rails_app", "svn2"
|
17
|
+
dependents.merge!(
|
18
|
+
:acts_as_list => GitRepositoryFromInternet.new("acts_as_list.git"),
|
19
|
+
:ssl_requirement => GitRepositoryFromInternet.new("ssl_requirement.git"),
|
20
|
+
:engines => Engines.new,
|
21
|
+
:redhillonrails_core => SvnRepositoryFromDump.new("redhillonrails_core"),
|
22
|
+
:empty_plugin => SvnRepositoryFromDump.new("empty_plugin"),
|
23
|
+
#fkm seems to cause problems when running tests, concerning a corrupt repository.
|
24
|
+
#commenting out for now.
|
25
|
+
#:foreign_key_migrations => SvnRepositoryFromDump.new("foreign_key_migrations", ""),
|
26
|
+
:rails => FakeRailsRepository.new,
|
27
|
+
:modules => ModulesSvnRepository.new,
|
28
|
+
:rails_app_unmanaged => RailsAppUnmanaged.new
|
29
|
+
)
|
30
|
+
|
31
|
+
dependents[:ssl_requirement].attributes[:revision] =
|
32
|
+
"aa2dded823f8a9b378c22ba0159971508918928a"
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_here
|
36
|
+
puts `svnadmin create #{name}`
|
37
|
+
raise unless $? == 0
|
38
|
+
|
39
|
+
mkdir_p "workdir"
|
40
|
+
Dir.chdir 'workdir' do
|
41
|
+
rm_rf_ie name
|
42
|
+
|
43
|
+
cmd = "svn checkout \"#{clean_url}\""
|
44
|
+
puts `#{cmd}`
|
45
|
+
raise unless $? == 0
|
46
|
+
|
47
|
+
Dir.entries(dependents[:rails_app_unmanaged].clean_dir).each do |file|
|
48
|
+
unless %w(.. .).include? file.to_s
|
49
|
+
cp_a File.join(dependents[:rails_app_unmanaged].clean_dir, file), name
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Dir.chdir name do
|
54
|
+
SvnProject.add_all
|
55
|
+
puts `svn commit -m "created initial project"`
|
56
|
+
raise unless $? == 0
|
57
|
+
|
58
|
+
`svn up`
|
59
|
+
raise unless $? == 0
|
60
|
+
|
61
|
+
Ext.run "init"
|
62
|
+
raise " could not create .externals" unless File.exists? '.externals'
|
63
|
+
|
64
|
+
# this line is necessary as ext can't perform the necessary
|
65
|
+
# ignores otherwise if vendor and vendor/plugins haven't been added
|
66
|
+
SvnProject.add_all
|
67
|
+
# puts `svn commit -m "added .externals file"`
|
68
|
+
# raise unless $? == 0
|
69
|
+
|
70
|
+
#install some git subprojects
|
71
|
+
Ext.run "install", dependents[:acts_as_list].clean_dir
|
72
|
+
#we have to use file:// to test export, because without that
|
73
|
+
#git clone optimizes by copying and igores --depth
|
74
|
+
Ext.run "install", "file://#{dependents[:rails].clean_dir}"
|
75
|
+
|
76
|
+
#install a couple svn managed subprojects
|
77
|
+
[
|
78
|
+
#:foreign_key_migrations,
|
79
|
+
:redhillonrails_core
|
80
|
+
].each do |proj|
|
81
|
+
Ext.run "install", "--svn", dependents[proj].clean_url
|
82
|
+
end
|
83
|
+
|
84
|
+
#install project with a git branch
|
85
|
+
Ext.run "install", dependents[:engines].clean_dir, "-b", "edge"
|
86
|
+
|
87
|
+
#install project with a non-default path
|
88
|
+
Ext.run "install", "--svn",
|
89
|
+
"#{dependents[:modules].clean_url}",
|
90
|
+
"modules"
|
91
|
+
|
92
|
+
SvnProject.add_all
|
93
|
+
|
94
|
+
puts `svn commit -m "created empty rails app with some subprojects"`
|
95
|
+
unless $? == 0
|
96
|
+
raise
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
rm_rf "workdir"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'externals/test/repository'
|
2
|
+
|
3
|
+
module Externals
|
4
|
+
module Test
|
5
|
+
class RailsAppUnmanaged < Repository
|
6
|
+
def initialize
|
7
|
+
super "rails_app", "unmanaged"
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_here
|
11
|
+
rm_rf name
|
12
|
+
if rails_version =~ /^3([^\d]|$)/
|
13
|
+
puts `#{rails_exe} new #{name}`
|
14
|
+
raise unless $? == 0
|
15
|
+
elsif rails_version =~ /^2([^\d]|$)/
|
16
|
+
puts `#{rails_exe} #{name}`
|
17
|
+
raise unless $? == 0
|
18
|
+
else
|
19
|
+
raise "can't determine rails version"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Externals
|
4
|
+
module Test
|
5
|
+
|
6
|
+
# repositories used for testing live in
|
7
|
+
#
|
8
|
+
# test/tmp/cleanreps
|
9
|
+
#
|
10
|
+
# and a backup is made in
|
11
|
+
#
|
12
|
+
# test/tmp/pristinereps
|
13
|
+
#
|
14
|
+
# reps in pristinereps are never written to, but a test can write to
|
15
|
+
# a rep in cleanreps. When this happens, the test needs to reset
|
16
|
+
# the rep in cleanreps. This can be done by simply deleting it. It
|
17
|
+
# will then be copied back over from pristinereps.
|
18
|
+
#
|
19
|
+
# a file is placed in these directories named .working_#{repname}
|
20
|
+
# when they are being built or copied. If present, Repository will not use
|
21
|
+
# that folder, and will instead delete it and recreate it.
|
22
|
+
#
|
23
|
+
class Repository
|
24
|
+
include ExtTestCase
|
25
|
+
|
26
|
+
attr_accessor :name, :subpath, :dependents, :attributes
|
27
|
+
|
28
|
+
def initialize name, subpath = ""
|
29
|
+
self.subpath = subpath
|
30
|
+
self.name = name
|
31
|
+
self.dependents ||= {}
|
32
|
+
self.attributes ||= {}
|
33
|
+
|
34
|
+
[
|
35
|
+
clean_dir_parent,
|
36
|
+
pristine_dir_parent
|
37
|
+
].each do |p|
|
38
|
+
FileUtils.mkdir_p p
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# the root location under which all clean repositories are stored for testing.
|
43
|
+
def clean_dir_root
|
44
|
+
File.join(root_dir, "test", "tmp", "cleanreps")
|
45
|
+
end
|
46
|
+
|
47
|
+
# One level up from the directory in which this repository's clean version is stored
|
48
|
+
def clean_dir_parent
|
49
|
+
if subpath.empty?
|
50
|
+
clean_dir_root
|
51
|
+
else
|
52
|
+
File.join clean_dir_root, subpath
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# The directory in which this repository's clean version is stored
|
57
|
+
def clean_dir
|
58
|
+
File.join clean_dir_parent, name
|
59
|
+
end
|
60
|
+
|
61
|
+
# the root location under which all pristine repositories are stored for testing.
|
62
|
+
def pristine_dir_root
|
63
|
+
File.join(root_dir, "test", "tmp", "pristinereps")
|
64
|
+
end
|
65
|
+
|
66
|
+
# One level up from the directory in which this repository's pristine version is stored
|
67
|
+
def pristine_dir_parent
|
68
|
+
if subpath.empty?
|
69
|
+
pristine_dir_root
|
70
|
+
else
|
71
|
+
File.join pristine_dir_root, subpath
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# The directory in which this repository's pristine version is stored
|
76
|
+
def pristine_dir
|
77
|
+
File.join pristine_dir_parent, name
|
78
|
+
end
|
79
|
+
|
80
|
+
# builds/copies the test repository if needed
|
81
|
+
def prepare
|
82
|
+
#let's mark ourselves as dirty if any of our dependents are dirty
|
83
|
+
if dependents.values.detect(&:'dirty?')
|
84
|
+
mark_dirty
|
85
|
+
end
|
86
|
+
dependents.values.each {|child| child.prepare}
|
87
|
+
|
88
|
+
if dirty?
|
89
|
+
delete_clean_dir
|
90
|
+
end
|
91
|
+
|
92
|
+
#if the directory is there, we don't need to do anything
|
93
|
+
if !File.exists? clean_dir
|
94
|
+
Dir.chdir clean_dir_parent do
|
95
|
+
mark_dirty
|
96
|
+
if pristine_exists? && !pristine_dirty?
|
97
|
+
copy_pristine_here
|
98
|
+
else
|
99
|
+
build_here
|
100
|
+
end
|
101
|
+
unmark_dirty
|
102
|
+
|
103
|
+
copy_clean_to_pristine
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def copy_clean_to_pristine
|
109
|
+
if pristine_exists? && pristine_dirty?
|
110
|
+
delete_pristine_dir
|
111
|
+
end
|
112
|
+
|
113
|
+
# if it exists, it's already done
|
114
|
+
if !File.exists? pristine_dir
|
115
|
+
pristine_mark_dirty
|
116
|
+
Dir.chdir pristine_dir_parent do
|
117
|
+
cp_a clean_dir, "."
|
118
|
+
end
|
119
|
+
pristine_unmark_dirty
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def copy_pristine_here
|
124
|
+
cp_a pristine_dir, "."
|
125
|
+
end
|
126
|
+
|
127
|
+
def pristine_exists?
|
128
|
+
File.exists? pristine_dir
|
129
|
+
end
|
130
|
+
|
131
|
+
def delete_clean_dir
|
132
|
+
Dir.chdir clean_dir_parent do
|
133
|
+
rm_rf_ie name
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def delete_pristine_dir
|
138
|
+
Dir.chdir pristine_dir_parent do
|
139
|
+
rm_rf_ie name
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def dirty?
|
144
|
+
Dir.chdir clean_dir_parent do
|
145
|
+
File.exists? working_file_name
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def mark_dirty
|
150
|
+
Dir.chdir clean_dir_parent do
|
151
|
+
File.open working_file_name, "w" do |file|
|
152
|
+
file.puts "dirty"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def unmark_dirty
|
158
|
+
Dir.chdir clean_dir_parent do
|
159
|
+
File.delete working_file_name
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def pristine_dirty?
|
164
|
+
Dir.chdir pristine_dir_parent do
|
165
|
+
File.exists? working_file_name
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def pristine_mark_dirty
|
170
|
+
Dir.chdir pristine_dir_parent do
|
171
|
+
File.open working_file_name, "w" do |file|
|
172
|
+
file.puts "dirty"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def pristine_unmark_dirty
|
178
|
+
Dir.chdir pristine_dir_parent do
|
179
|
+
File.delete working_file_name
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def working_file_name
|
184
|
+
".working_#{name}"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'externals/test/repository'
|
2
|
+
require 'externals/test/svn_repository_helper'
|
3
|
+
|
4
|
+
module Externals
|
5
|
+
module Test
|
6
|
+
class SvnRepositoryFromDump < Repository
|
7
|
+
include SvnRepositoryHelper
|
8
|
+
|
9
|
+
def initialize name, subpath = nil
|
10
|
+
super name, subpath || "svn"
|
11
|
+
end
|
12
|
+
|
13
|
+
#builds the test repository in the current directory
|
14
|
+
def build_here
|
15
|
+
cp_a File.join(root_dir, "test", "setup", "#{name}.svn.gz"), "."
|
16
|
+
|
17
|
+
puts `gzip -f -d #{name}.svn.gz`
|
18
|
+
raise unless $? == 0
|
19
|
+
puts `svnadmin create #{name}`
|
20
|
+
raise unless $? == 0
|
21
|
+
puts `svnadmin load #{name} < #{name}.svn`
|
22
|
+
raise unless $? == 0
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/externals/test_case.rb
CHANGED
@@ -1,198 +1,35 @@
|
|
1
1
|
require 'test/unit'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
module Externals
|
4
5
|
TestCase = Test::Unit::TestCase
|
5
6
|
module ExtTestCase
|
6
|
-
|
7
|
-
|
8
|
-
def initialize_test_git_repository
|
9
|
-
scm = 'git'
|
10
|
-
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..', 'test')) do
|
11
|
-
`mkdir repositories` unless File.exists? 'repositories'
|
12
|
-
Dir.chdir 'repositories' do
|
13
|
-
`mkdir #{scm}repo`
|
14
|
-
Dir.chdir("#{scm}repo") do
|
15
|
-
`git init`
|
16
|
-
open 'readme.txt', 'w' do |f|
|
17
|
-
f.write "readme.txt Line 1
|
18
|
-
Line 2
|
19
|
-
Line 3"
|
20
|
-
end
|
21
|
-
|
22
|
-
`git add .`
|
23
|
-
`git commit -m "added readme.txt"`
|
24
|
-
|
25
|
-
open 'readme.txt', 'a' do |f|
|
26
|
-
f.write "line 4"
|
27
|
-
end
|
28
|
-
|
29
|
-
`git add .`
|
30
|
-
`git commit -m "added a line to readme.txt"`
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def initialize_test_svn_repository
|
37
|
-
scm = 'svn'
|
38
|
-
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..', 'test')) do
|
39
|
-
`mkdir repositories` unless File.exists? 'repositories'
|
40
|
-
Dir.chdir 'repositories' do
|
41
|
-
puts `svnadmin create #{scm}repo`
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def destroy_test_repository scm
|
47
|
-
puts(rmcmd = "rm -rf #{repository_dir(scm)}")
|
48
|
-
puts `#{rmcmd}`
|
49
|
-
end
|
50
|
-
|
51
|
-
def repository_dir scm = nil
|
52
|
-
if scm.nil?
|
53
|
-
File.join(File.dirname(__FILE__), '..', '..', 'test', 'repositories')
|
54
|
-
else
|
55
|
-
File.expand_path(File.join(repository_dir, "#{scm}repo"))
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def create_test_modules_repository scm
|
60
|
-
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..', 'test')) do
|
61
|
-
`mkdir repositories` unless File.exists? 'repositories'
|
62
|
-
Dir.chdir 'repositories' do
|
63
|
-
puts `svnadmin create #{scm}modulesrepo`
|
64
|
-
end
|
65
|
-
|
66
|
-
cmd = "svn checkout \"file:///#{File.expand_path(File.join('repositories', "#{scm}modulesrepo"))}\""
|
67
|
-
puts "about to run #{cmd}"
|
68
|
-
puts `#{cmd}`
|
69
|
-
Dir.chdir "#{scm}modulesrepo" do
|
70
|
-
if !File.exists? 'modules.txt'
|
71
|
-
open("modules.txt", "w") do |f|
|
72
|
-
f.write "line1 of modules.txt\n"
|
73
|
-
end
|
74
|
-
|
75
|
-
SvnProject.add_all
|
76
|
-
puts `svn commit -m "created modules.txt"`
|
77
|
-
end
|
78
|
-
end
|
79
|
-
`rm -rf #{scm}modulesrepo`
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def with_svn_branches_modules_repository_dir
|
84
|
-
File.expand_path(File.join(repository_dir, with_svn_branches_modules_repository_name))
|
85
|
-
end
|
86
|
-
def with_svn_branches_modules_repository_url
|
87
|
-
url = "file:///#{with_svn_branches_modules_repository_dir}"
|
88
|
-
if windows?
|
89
|
-
url.gsub!(/\\/, "/")
|
90
|
-
end
|
91
|
-
url.gsub("file:////", 'file:///')
|
92
|
-
end
|
93
|
-
def with_svn_branches_repository_url
|
94
|
-
url = "file:///#{with_svn_branches_repository_dir}"
|
95
|
-
if windows?
|
96
|
-
url.gsub!(/\\/, "/")
|
97
|
-
end
|
98
|
-
url.gsub("file:////", 'file:///')
|
99
|
-
end
|
100
|
-
|
101
|
-
def with_svn_branches_modules_repository_name
|
102
|
-
'svnmodulesbranchesrepo'
|
103
|
-
end
|
104
|
-
def with_svn_branches_repository_dir
|
105
|
-
File.expand_path(File.join(repository_dir, with_svn_branches_repository_name))
|
106
|
-
end
|
107
|
-
def with_svn_branches_repository_name
|
108
|
-
'svnbranchesrepo'
|
109
|
-
end
|
110
|
-
|
111
|
-
def destroy_with_svn_branches_modules_repository
|
112
|
-
Dir.chdir repository_dir do
|
113
|
-
`rm -rf #{with_svn_branches_modules_repository_name}`
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def destroy_with_svn_branches_repository
|
118
|
-
Dir.chdir repository_dir do
|
119
|
-
`rm -rf #{with_svn_branches_repository_name}`
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def create_with_svn_branches_modules_repository
|
124
|
-
Dir.chdir(File.join(root_dir, 'test')) do
|
125
|
-
`mkdir repositories` unless File.exists? 'repositories'
|
126
|
-
Dir.chdir repository_dir do
|
127
|
-
puts `svnadmin create #{with_svn_branches_modules_repository_name}`
|
128
|
-
end
|
129
|
-
|
130
|
-
`mkdir workdir` unless File.exists? 'workdir'
|
131
|
-
Dir.chdir 'workdir' do
|
132
|
-
cmd = "svn checkout \"#{with_svn_branches_modules_repository_url}\""
|
133
|
-
puts "about to run #{cmd}"
|
134
|
-
puts `#{cmd}`
|
135
|
-
raise unless $? == 0
|
136
|
-
|
137
|
-
Dir.chdir with_svn_branches_modules_repository_name do
|
138
|
-
`mkdir branches`
|
139
|
-
`mkdir current`
|
7
|
+
include FileUtils
|
140
8
|
|
141
|
-
|
142
|
-
puts `svn commit -m "created branch directory structure"`
|
143
|
-
raise unless $? == 0
|
9
|
+
protected
|
144
10
|
|
145
|
-
|
146
|
-
|
147
|
-
|
11
|
+
def mark_dirty file
|
12
|
+
File.open working_file_name(file), "w" do |file|
|
13
|
+
file.puts "dirty"
|
148
14
|
end
|
149
15
|
end
|
150
|
-
def create_with_svn_branches_repository
|
151
|
-
Dir.chdir(File.join(root_dir, 'test')) do
|
152
|
-
`mkdir repositories` unless File.exists? 'repositories'
|
153
|
-
Dir.chdir repository_dir do
|
154
|
-
puts `svnadmin create #{with_svn_branches_repository_name}`
|
155
|
-
end
|
156
|
-
|
157
|
-
`mkdir workdir` unless File.exists? 'workdir'
|
158
|
-
Dir.chdir 'workdir' do
|
159
|
-
cmd = "svn checkout \"#{with_svn_branches_repository_url}\""
|
160
|
-
puts "about to run #{cmd}"
|
161
|
-
puts `#{cmd}`
|
162
|
-
raise unless $? == 0
|
163
|
-
|
164
|
-
Dir.chdir with_svn_branches_repository_name do
|
165
|
-
`mkdir branches`
|
166
|
-
`mkdir current`
|
167
|
-
|
168
|
-
SvnProject.add_all
|
169
|
-
puts `svn commit -m "created branch directory structure"`
|
170
|
-
raise unless $? == 0
|
171
16
|
|
172
|
-
|
173
|
-
|
174
|
-
end
|
175
|
-
end
|
17
|
+
def unmark_dirty file
|
18
|
+
File.delete working_file_name(file)
|
176
19
|
end
|
177
20
|
|
178
|
-
def
|
179
|
-
|
180
|
-
puts `#{rmcmd}`
|
21
|
+
def working_file_name file
|
22
|
+
".working_#{file}"
|
181
23
|
end
|
182
24
|
|
183
|
-
def
|
184
|
-
File.
|
25
|
+
def dirty?(file)
|
26
|
+
File.exists? working_file_name(file)
|
185
27
|
end
|
186
28
|
|
187
|
-
def
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
puts `#{rails_exe} new rails_app`
|
192
|
-
elsif rails_version =~ /^2([^\d]|$)/
|
193
|
-
puts `#{rails_exe} rails_app`
|
194
|
-
else
|
195
|
-
raise "can't determine rails version"
|
29
|
+
def delete_if_dirty file
|
30
|
+
if File.exists? file
|
31
|
+
if dirty?(file)
|
32
|
+
rm_r file
|
196
33
|
end
|
197
34
|
end
|
198
35
|
end
|
@@ -210,136 +47,8 @@ module Externals
|
|
210
47
|
ENV['OS'] =~ /^Win/i
|
211
48
|
end
|
212
49
|
|
213
|
-
def destroy_rails_application
|
214
|
-
Dir.chdir applications_dir do
|
215
|
-
`rm -rf rails_app`
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
50
|
def root_dir
|
220
51
|
File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
221
52
|
end
|
222
|
-
|
223
|
-
def applications_dir
|
224
|
-
File.join(root_dir, 'test', 'applications')
|
225
|
-
end
|
226
|
-
|
227
|
-
def rails_application_dir
|
228
|
-
File.join(applications_dir, 'rails_app')
|
229
|
-
end
|
230
|
-
|
231
|
-
def initialize_with_svn_branches_repository
|
232
|
-
Dir.chdir File.join(root_dir, 'test') do
|
233
|
-
repo_url = with_svn_branches_repository_url
|
234
|
-
|
235
|
-
Dir.chdir 'workdir' do
|
236
|
-
puts `svn co #{[repo_url, "current"].join("/")} rails_app`
|
237
|
-
raise unless $? == 0
|
238
|
-
Dir.chdir "rails_app" do
|
239
|
-
puts `cp -r #{rails_application_dir}/* .`
|
240
|
-
raise unless $? == 0
|
241
|
-
|
242
|
-
Ext.run "init", "-b", "current"
|
243
|
-
|
244
|
-
# this line is necessary as ext can't perform the necessary
|
245
|
-
# ignores otherwise if vendor and vendor/plugins haven't been added
|
246
|
-
SvnProject.add_all
|
247
|
-
|
248
|
-
raise " could not create .externals" unless File.exists? '.externals'
|
249
|
-
%w(rails acts_as_list).each do |proj|
|
250
|
-
Ext.run "install", File.join(root_dir, 'test', 'cleanreps', "#{proj}.git")
|
251
|
-
end
|
252
|
-
|
253
|
-
#install a couple svn managed subprojects
|
254
|
-
%w(foreign_key_migrations redhillonrails_core).each do |proj|
|
255
|
-
Ext.run "install", "--svn", "file:///#{File.join(root_dir, 'test', 'cleanreps', proj)}"
|
256
|
-
end
|
257
|
-
|
258
|
-
#install project with a git branch
|
259
|
-
Ext.run "install", File.join(root_dir, 'test', 'cleanreps', 'engines.git'), "-b", "edge"
|
260
|
-
|
261
|
-
#install project with a non-default path and svn branching
|
262
|
-
Ext.run "install", "--svn",
|
263
|
-
"#{with_svn_branches_modules_repository_url}",
|
264
|
-
"-b", "current",
|
265
|
-
"modules"
|
266
|
-
|
267
|
-
SvnProject.add_all
|
268
|
-
|
269
|
-
puts `svn commit -m "created empty rails app with some subprojects"`
|
270
|
-
raise unless $? == 0
|
271
|
-
|
272
|
-
# now let's make a branch in the main project called new_branch
|
273
|
-
`svn copy #{
|
274
|
-
[repo_url, "current"].join("/")
|
275
|
-
} #{[repo_url, "branches", "new_branch"].join("/")} -m "creating branch" `
|
276
|
-
raise unless $? == 0
|
277
|
-
|
278
|
-
# let's make a branch in a git subproject:
|
279
|
-
Dir.chdir File.join(%w(vendor plugins engines)) do
|
280
|
-
`git push origin master:branch1`
|
281
|
-
raise unless $? == 0
|
282
|
-
end
|
283
|
-
|
284
|
-
# let's update the .externals file in new_branch to reflect these changes
|
285
|
-
`svn switch #{[repo_url, "branches", "new_branch"].join("/")}`
|
286
|
-
raise unless $? == 0
|
287
|
-
|
288
|
-
# let's remove rails from this branch
|
289
|
-
Ext.run "uninstall", "-f", "rails"
|
290
|
-
|
291
|
-
ext = Ext.new
|
292
|
-
ext.configuration["vendor/plugins/engines"]["branch"] = "branch1"
|
293
|
-
ext.configuration["modules"]["branch"] = "branches/branch2"
|
294
|
-
ext.configuration.write
|
295
|
-
|
296
|
-
SvnProject.add_all
|
297
|
-
`svn commit -m "updated .externals to point to new branches."`
|
298
|
-
raise unless $? == 0
|
299
|
-
end
|
300
|
-
|
301
|
-
`rm -rf rails_app`
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
def initialize_with_svn_branches_modules_repository
|
307
|
-
Dir.chdir File.join(root_dir, 'test') do
|
308
|
-
repo_url = with_svn_branches_modules_repository_url
|
309
|
-
|
310
|
-
Dir.chdir 'workdir' do
|
311
|
-
puts `svn co #{[repo_url, "current"].join("/")} modules`
|
312
|
-
raise unless $? == 0
|
313
|
-
Dir.chdir "modules" do
|
314
|
-
if !File.exists? 'modules.txt'
|
315
|
-
open("modules.txt", "w") do |f|
|
316
|
-
f.write "line1 of modules.txt\n"
|
317
|
-
end
|
318
|
-
|
319
|
-
SvnProject.add_all
|
320
|
-
puts `svn commit -m "created modules.txt"`
|
321
|
-
raise unless $? == 0
|
322
|
-
end
|
323
|
-
|
324
|
-
`svn copy #{
|
325
|
-
[repo_url, "current"].join("/")
|
326
|
-
} #{[repo_url, "branches", "branch2"].join("/")
|
327
|
-
} -m "created branch2"`
|
328
|
-
raise unless $? == 0
|
329
|
-
|
330
|
-
puts `svn switch #{
|
331
|
-
[repo_url, "branches", "branch2"].join("/")
|
332
|
-
}`
|
333
|
-
raise unless $? == 0
|
334
|
-
`echo 'line 2 of modules.txt ... this is branch2!' > modules.txt`
|
335
|
-
SvnProject.add_all
|
336
|
-
puts `svn commit -m "changed modules.txt"`
|
337
|
-
raise unless $? == 0
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
|
344
53
|
end
|
345
54
|
end
|