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.
Files changed (43) hide show
  1. data/CHANGELOG +7 -0
  2. data/README +2 -0
  3. data/Rakefile +1 -74
  4. data/bin/ext +0 -0
  5. data/lib/externals/ext.rb +25 -9
  6. data/lib/externals/extensions/file_utils.rb +40 -0
  7. data/lib/externals/extensions/string.rb +1 -1
  8. data/lib/externals/project.rb +3 -0
  9. data/lib/externals/scms/git_project.rb +3 -4
  10. data/lib/externals/scms/svn_project.rb +10 -12
  11. data/lib/externals/test/basic_git_repository.rb +41 -0
  12. data/lib/externals/test/engines.rb +11 -0
  13. data/lib/externals/test/engines_with_branch1.rb +36 -0
  14. data/lib/externals/test/fake_rails_repository.rb +112 -0
  15. data/lib/externals/test/git_repository_from_internet.rb +19 -0
  16. data/lib/externals/test/modules_svn_branches_repository.rb +72 -0
  17. data/lib/externals/test/modules_svn_repository.rb +41 -0
  18. data/lib/externals/test/rails_app_git_branches.rb +100 -0
  19. data/lib/externals/test/rails_app_git_repository.rb +55 -0
  20. data/lib/externals/test/rails_app_svn_branches.rb +132 -0
  21. data/lib/externals/test/rails_app_svn_repository.rb +106 -0
  22. data/lib/externals/test/rails_app_unmanaged.rb +25 -0
  23. data/lib/externals/test/repository.rb +188 -0
  24. data/lib/externals/test/svn_repository_from_dump.rb +27 -0
  25. data/lib/externals/test/svn_repository_helper.rb +10 -0
  26. data/lib/externals/test_case.rb +16 -307
  27. data/test/setup/empty_plugin.svn.gz +0 -0
  28. data/test/setup/foreign_key_migrations.svn.gz +0 -0
  29. data/test/setup/redhillonrails_core.svn.gz +0 -0
  30. data/test/test_checkout_git.rb +16 -25
  31. data/test/test_checkout_with_subprojects_git.rb +109 -193
  32. data/test/test_checkout_with_subprojects_svn.rb +239 -294
  33. data/test/test_file_utils_extensions.rb +29 -0
  34. data/test/test_freeze_to_revision.rb +46 -85
  35. data/test/test_git_project_extract_name.rb +10 -8
  36. data/test/test_init_git.rb +19 -29
  37. data/test/test_projects.rb +87 -93
  38. data/test/test_rails_detection.rb +12 -17
  39. data/test/test_string_extensions.rb +32 -30
  40. data/test/test_svn_branches.rb +227 -383
  41. data/test/test_touch_emptydirs.rb +39 -34
  42. data/test/test_version.rb +18 -16
  43. metadata +47 -23
@@ -1,39 +1,30 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
2
  require 'externals/test_case'
3
3
  require 'externals/ext'
4
+ require 'externals/test/basic_git_repository'
4
5
 
5
6
  module Externals
6
- class TestCheckoutGit < TestCase
7
- include ExtTestCase
7
+ module Test
8
+ class TestCheckoutGit < TestCase
9
+ include ExtTestCase
8
10
 
9
- def setup
10
- initialize_test_git_repository
11
+ def test_checkout
12
+ repository = BasicGitRepository.new
13
+ repository.prepare
11
14
 
12
- Dir.chdir File.join(root_dir, 'test') do
13
- `rm -rf workdir`
14
- end
15
- end
16
-
17
- def teardown
18
- destroy_test_repository 'git'
19
- Dir.chdir File.join(root_dir, 'test') do
20
- `rm -rf workdir`
21
- end
15
+ assert File.exists?(File.join(repository.clean_dir, ".git"))
22
16
 
23
- end
24
-
25
- def test_repository_created
26
- assert File.exists?(File.join(repository_dir('git'), '.git'))
27
- end
17
+ workdir = File.join(root_dir, 'test', "tmp", "workdir")
18
+ mkdir_p workdir
28
19
 
29
- def test_checkout
30
- Dir.chdir File.join(root_dir, 'test') do
31
- `mkdir workdir`
20
+ Dir.chdir workdir do
21
+ if File.exists?(repository.name)
22
+ rm_r repository.name
23
+ end
32
24
 
33
- Dir.chdir 'workdir' do
34
- Ext.run "checkout", "--git", repository_dir('git')
25
+ Ext.run "checkout", "--git", repository.clean_dir
35
26
 
36
- assert File.exists?(File.join(repository_dir('git'),'.git'))
27
+ assert File.exists?(File.join(repository.name, "readme.txt"))
37
28
  end
38
29
  end
39
30
  end
@@ -1,251 +1,167 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
2
  require 'externals/test_case'
3
3
  require 'externals/ext'
4
+ require 'externals/test/rails_app_git_branches'
4
5
 
5
6
  module Externals
6
- class TestCheckoutWithSubprojectsGit < TestCase
7
- include ExtTestCase
8
-
9
- def setup
10
- destroy_rails_application
11
- create_rails_application
12
-
13
- Dir.chdir File.join(root_dir, 'test') do
14
- parts = 'workdir/checkout/rails_app/vendor/plugins/foreign_key_migrations/lib/red_hill_consulting/foreign_key_migrations/active_record/connection_adapters/.svn/text-base/table_definition.rb.svn-base'.split('/')
15
- if File.exists? File.join(*parts)
16
- Dir.chdir File.join(*(parts[0..-2])) do
17
- File.delete parts[-1]
18
- end
19
- end
20
- `rm -rf workdir`
21
- `mkdir workdir`
22
- `cp -r #{rails_application_dir} workdir`
23
- Dir.chdir File.join('workdir','rails_app') do
24
- Ext.run "touch_emptydirs"
25
-
26
- `git init`
27
- Ext.run "init"
28
- raise " could not create .externals" unless File.exists? '.externals'
29
- Ext.run "install", File.join(root_dir, 'test', 'cleanreps', "acts_as_list.git")
30
-
31
- #install a couple svn managed subprojects
32
- %w(foreign_key_migrations redhillonrails_core).each do |proj|
33
- Ext.run "install", "--svn", 'file:///' +
34
- File.join(root_dir, 'test', 'cleanreps', proj)
35
- end
7
+ module Test
8
+ class TestCheckoutWithSubprojectsGit < TestCase
9
+ include ExtTestCase
36
10
 
37
- ext = Ext.new
38
- main_project = ext.main_project
11
+ def test_checkout_with_subproject
12
+ repository = RailsAppGitBranches.new
13
+ repository.prepare
39
14
 
40
- unless !main_project.ignore_contains? "vendor/plugins/engines"
41
- raise
42
- end
43
- #install project with a branch
44
- Ext.run "install", File.join(root_dir, 'test', 'cleanreps', 'engines.git'), "-b", "edge"
45
- unless main_project.ignore_contains? "vendor/plugins/engines"
46
- raise
47
- end
15
+ assert File.exists?(File.join(repository.clean_dir, "db"))
48
16
 
49
- #install fake_rails
50
- unless !main_project.ignore_contains? "vendor/rails"
51
- raise
52
- end
53
- Ext.run "install",
54
- "--git",
55
- File.join(root_dir, 'test', 'cleanreps', 'fake_rails'),
56
- "vendor/rails"
57
- unless main_project.ignore_contains? "vendor/rails"
58
- raise
59
- end
17
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", "branches", "git")
18
+ mkdir_p workdir
60
19
 
61
-
62
- GitProject.add_all
63
- `git commit -m "created empty rails app with some subprojects"`
20
+ if File.exists?(File.join(workdir,"rails_app"))
21
+ rm_rf File.join(workdir, "rails_app")
64
22
  end
65
- end
66
- end
67
23
 
68
- def teardown
69
- destroy_rails_application
24
+ Dir.chdir workdir do
25
+ source = repository.clean_dir
26
+ puts "About to checkout #{source}"
27
+ Ext.run "checkout", "--git", source
70
28
 
71
- Dir.chdir File.join(root_dir, 'test') do
72
- parts = 'workdir/checkout/rails_app/vendor/plugins/foreign_key_migrations/lib/red_hill_consulting/foreign_key_migrations/active_record/connection_adapters/.svn/text-base/table_definition.rb.svn-base'.split('/')
73
- if File.exists? File.join(*parts)
74
- Dir.chdir File.join(*(parts[0..-2])) do
75
- File.delete parts[-1]
76
- end
77
- end
78
- `rm -rf workdir`
79
- end
80
- Dir.chdir File.join(root_dir, 'test') do
81
- `rm -rf workdir`
82
- end
83
- end
29
+ Dir.chdir 'rails_app' do
30
+ assert File.exists?('.git')
84
31
 
85
- def test_checkout_with_subproject
86
- Dir.chdir File.join(root_dir, 'test') do
87
- Dir.chdir 'workdir' do
88
- `mkdir checkout`
89
- Dir.chdir 'checkout' do
90
- source = File.join(root_dir, 'test', 'workdir', 'rails_app')
91
- puts "About to checkout #{source}"
92
- Ext.run "checkout", "--git", source
32
+ assert File.exists?('.gitignore')
93
33
 
94
- Dir.chdir 'rails_app' do
95
- assert File.exists?('.git')
34
+ ext = Ext.new
35
+ main_project = ext.main_project
36
+ engines = ext.subproject("engines")
96
37
 
97
- assert File.exists?('.gitignore')
38
+ main_project.assert_e_dne_i_ni proc{|a|assert(a)},%w(foreign_key_migrations redhillonrails_core acts_as_list)
98
39
 
99
- ext = Ext.new
100
- main_project = ext.main_project
101
- engines = ext.subproject("engines")
40
+ # let's test switching branches via altering .externals and running "ext up"
41
+ assert_equal "master", main_project.current_branch
42
+ assert_equal "edge", engines.current_branch
43
+ assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
102
44
 
103
- main_project.assert_e_dne_i_ni proc{|a|assert(a)},%w(foreign_key_migrations redhillonrails_core acts_as_list)
45
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
104
46
 
105
- # let's test switching branches via altering .externals and running "ext up"
106
- assert_equal "master", main_project.current_branch
107
- assert_equal "edge", engines.current_branch
108
- assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
47
+ `git checkout --track -b new_branch origin/new_branch`
48
+ raise unless $? == 0
109
49
 
110
- #let's create a branch for the main project called 'new_branch' and a
111
- #branch for the engines subproject called 'new_branch' and make sure
112
- #that checking one out and doing "ext up" correctly changes the branch
113
- #of the subproject
50
+ assert_equal "new_branch", main_project.current_branch
51
+ assert_equal "edge", engines.current_branch
114
52
 
115
- `git push origin master:new_branch`
116
- raise unless $? == 0
53
+ assert_equal "new_branch", main_project.current_branch
117
54
 
118
- `git fetch origin`
119
- raise unless $? == 0
120
55
 
121
- `git checkout --track -b new_branch origin/new_branch`
122
- raise unless $? == 0
56
+ ext = Ext.new
57
+ assert_equal "branch1", ext.configuration["vendor/plugins/engines"]["branch"]
123
58
 
124
- assert_equal "new_branch", main_project.current_branch
125
- assert_equal "edge", engines.current_branch
59
+ assert !main_project.ignore_contains?("vendor/rails")
126
60
 
127
- Dir.chdir File.join(%w(vendor plugins engines)) do
128
- `git push origin master:new_branch`
129
- raise unless $? == 0
130
- end
131
- assert_equal "new_branch", main_project.current_branch
61
+ rm_rf "vendor/rails"
62
+ raise if File.exists?(File.join("vendor", "rails"))
132
63
 
133
- #update .externals
134
- ext.configuration["vendor/plugins/engines"]["branch"] = "new_branch"
135
- ext.configuration.write
64
+ `git checkout master`
65
+ raise unless $? == 0
136
66
 
137
- ext = Ext.new
138
- assert_equal "new_branch", ext.configuration["vendor/plugins/engines"]["branch"]
67
+ assert_equal "master", main_project.current_branch
68
+ assert_equal "edge", engines.current_branch
139
69
 
140
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
141
- #let's uninstall rails
142
- Ext.run "uninstall", "-f", "rails"
143
- assert !File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
70
+ Ext.run "up"
71
+ assert_equal "master", main_project.current_branch
72
+ assert_equal "edge", engines.current_branch
73
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
144
74
 
145
- GitProject.add_all
146
- raise unless $? == 0
147
- `git commit -m "changed branch on engines subproject"`
148
- raise unless $? == 0
149
- `git push`
150
- raise unless $? == 0
75
+ `git checkout new_branch`
76
+ assert_equal "new_branch", main_project.current_branch
77
+ assert_equal "edge", engines.current_branch
151
78
 
152
- `git checkout master`
153
- raise unless $? == 0
79
+ Ext.run "up"
80
+ assert_equal "new_branch", main_project.current_branch
81
+ assert_equal "branch1", engines.current_branch
154
82
 
155
- assert_equal "master", main_project.current_branch
156
- assert_equal "edge", engines.current_branch
83
+ `git checkout master`
84
+ Ext.run "up"
85
+ assert_equal "master", main_project.current_branch
86
+ assert_equal "edge", engines.current_branch
157
87
 
158
- Ext.run "up"
159
- assert_equal "master", main_project.current_branch
160
- assert_equal "edge", engines.current_branch
161
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
88
+ assert main_project.ignore_contains?("vendor/rails")
162
89
 
163
- `git checkout new_branch`
164
- assert_equal "new_branch", main_project.current_branch
165
- assert_equal "edge", engines.current_branch
90
+ #let's test the switch command!
91
+ Ext.run "switch", "new_branch"
92
+ assert_equal "new_branch", main_project.current_branch
93
+ assert_equal "branch1", engines.current_branch
166
94
 
167
- Ext.run "up"
168
- assert_equal "new_branch", main_project.current_branch
169
- assert_equal "new_branch", engines.current_branch
95
+ assert !main_project.ignore_contains?("vendor/rails")
96
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
97
+ rm_rf "vendor/rails"
170
98
 
171
- `git checkout master`
172
- Ext.run "up"
173
- assert_equal "master", main_project.current_branch
174
- assert_equal "edge", engines.current_branch
99
+ Ext.run "switch", "master"
100
+ assert_equal "master", main_project.current_branch
101
+ assert_equal "edge", engines.current_branch
175
102
 
176
- assert main_project.ignore_contains?("vendor/rails")
103
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
177
104
 
178
- #let's test the switch command!
179
- Ext.run "switch", "new_branch"
180
- assert_equal "new_branch", main_project.current_branch
181
- assert_equal "new_branch", engines.current_branch
105
+ assert main_project.ignore_contains?("vendor/rails")
106
+ end
182
107
 
183
- assert !main_project.ignore_contains?("vendor/rails")
184
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
185
- `rm -rf vendor/rails`
186
- assert !File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
187
- raise unless $? == 0
108
+ #now let's check it out again to test "ext checkout -b new_branch"
109
+ rm_rf "rails_app"
110
+ raise if File.exists?("rails_app")
188
111
 
189
- Ext.run "switch", "master"
190
- assert_equal "master", main_project.current_branch
191
- assert_equal "edge", engines.current_branch
112
+ Ext.run "checkout", "--git", "-b", "new_branch", source
192
113
 
193
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
114
+ Dir.chdir 'rails_app' do
115
+ ext = Ext.new
116
+ main_project = ext.main_project
117
+ engines = ext.subproject("engines")
194
118
 
195
- assert main_project.ignore_contains?("vendor/rails")
196
- end
119
+ assert_equal "new_branch", main_project.current_branch
120
+ assert_equal "branch1", engines.current_branch
121
+ end
122
+ end
123
+ end
197
124
 
198
- #now let's check it out again to test "ext checkout -b new_branch"
199
- `rm -rf rails_app`
200
- raise unless $? == 0
125
+ def test_uninstall
126
+ repository = RailsAppGitBranches.new
127
+ repository.prepare
201
128
 
202
- Ext.run "checkout", "--git", "-b", "new_branch", source
129
+ assert File.exists?(File.join(repository.clean_dir, "db"))
203
130
 
204
- Dir.chdir 'rails_app' do
205
- ext = Ext.new
206
- main_project = ext.main_project
207
- engines = ext.subproject("engines")
131
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", "branches", "uninstall", "git")
132
+ mkdir_p workdir
208
133
 
209
- assert_equal "new_branch", main_project.current_branch
210
- assert_equal "new_branch", engines.current_branch
211
- end
212
- end
134
+ if File.exists?(File.join(workdir,"rails_app"))
135
+ rm_rf File.join(workdir, "rails_app")
213
136
  end
214
- end
215
- end
216
137
 
217
- def test_uninstall
218
- Dir.chdir File.join(root_dir, 'test') do
219
- Dir.chdir 'workdir' do
220
- `mkdir checkout`
221
- Dir.chdir 'checkout' do
222
- source = File.join(root_dir, 'test', 'workdir', 'rails_app')
223
- puts "About to checkout #{source}"
224
- Ext.run "checkout", "--git", source
138
+ Dir.chdir workdir do
139
+ source = repository.clean_dir
140
+ puts "About to checkout #{source}"
141
+ Ext.run "checkout", "--git", source
225
142
 
226
- Dir.chdir 'rails_app' do
227
- mp = Ext.new.main_project
143
+ Dir.chdir 'rails_app' do
144
+ mp = Ext.new.main_project
228
145
 
229
- projs = %w(foreign_key_migrations redhillonrails_core acts_as_list)
230
- projs_i = projs.dup
231
- projs_ni = []
146
+ projs = %w(foreign_key_migrations redhillonrails_core acts_as_list)
147
+ projs_i = projs.dup
148
+ projs_ni = []
232
149
 
233
- #let's uninstall acts_as_list
234
- Ext.run "uninstall", "acts_as_list"
150
+ #let's uninstall acts_as_list
151
+ Ext.run "uninstall", "acts_as_list"
235
152
 
236
- projs_ni << projs_i.delete('acts_as_list')
153
+ projs_ni << projs_i.delete('acts_as_list')
237
154
 
238
- mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, [], projs_i, projs_ni
155
+ mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, [], projs_i, projs_ni
239
156
 
240
- Ext.run "uninstall", "-f", "foreign_key_migrations"
157
+ Ext.run "uninstall", "-f", "foreign_key_migrations"
241
158
 
242
- projs_ni << projs_i.delete('foreign_key_migrations')
159
+ projs_ni << projs_i.delete('foreign_key_migrations')
243
160
 
244
- projs_dne = []
245
- projs_dne << projs.delete('foreign_key_migrations')
161
+ projs_dne = []
162
+ projs_dne << projs.delete('foreign_key_migrations')
246
163
 
247
- mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, projs_dne, projs_i, projs_ni
248
- end
164
+ mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, projs_dne, projs_i, projs_ni
249
165
  end
250
166
  end
251
167
  end
@@ -1,402 +1,347 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
+
2
3
  require 'externals/test_case'
3
4
  require 'externals/ext'
5
+ require 'externals/test/rails_app_svn_repository'
4
6
 
5
7
  module Externals
6
- class TestCheckoutWithSubprojectsSvn < TestCase
7
- include ExtTestCase
8
-
9
- def setup
10
- destroy_rails_application
11
- create_rails_application
12
- destroy_test_repository 'svn'
13
- initialize_test_svn_repository
14
- destroy_test_modules_repository 'svn'
15
- create_test_modules_repository 'svn'
16
-
17
- Dir.chdir File.join(root_dir, 'test') do
18
- parts = 'workdir/checkout/rails_app/vendor/plugins/foreign_key_migrations/lib/red_hill_consulting/foreign_key_migrations/active_record/connection_adapters/.svn/text-base/table_definition.rb.svn-base'.split('/')
19
- if File.exists? File.join(*parts)
20
- Dir.chdir File.join(*(parts[0..-2])) do
21
- File.delete parts[-1]
22
- end
23
- end
24
-
25
- `rm -rf workdir`
26
- repo_url = repository_dir('svn')
27
- if windows?
28
- repo_url = repo_url.gsub(/\\/, "/")
29
- end
30
-
31
- puts `svn co file:///#{repository_dir('svn')} #{File.join("workdir","rails_app")}`
32
- Dir.chdir File.join('workdir', "rails_app") do
33
- puts `cp -r #{rails_application_dir}/* .`
34
-
35
- SvnProject.add_all
36
-
37
- Ext.run "init"
38
- raise " could not create .externals" unless File.exists? '.externals'
39
- %w(rails acts_as_list).each do |proj|
40
- Ext.run "install", File.join(root_dir, 'test', 'cleanreps', "#{proj}.git")
41
- end
42
-
43
- #install a couple svn managed subprojects
44
- %w(foreign_key_migrations redhillonrails_core).each do |proj|
45
- Ext.run "install", "--svn", "file:///#{File.join(root_dir, 'test', 'cleanreps', proj)}"
46
- end
47
-
48
- #install project with a branch
49
- Ext.run "install", File.join(root_dir, 'test', 'cleanreps', 'engines.git'), "-b", "edge"
50
-
51
- #install project with a non-default path
52
- Ext.run "install", "--svn", "file:///#{modules_repository_dir('svn')}", "modules"
53
-
54
- SvnProject.add_all
55
-
56
- puts `svn commit -m "created empty rails app with some subprojects"`
57
- end
58
- end
59
- end
60
-
61
- def teardown
62
- destroy_rails_application
63
- destroy_test_repository 'svn'
64
- destroy_test_modules_repository 'svn'
65
-
8
+ module Test
9
+ class TestCheckoutWithSubprojectsSvn < TestCase
10
+ include ExtTestCase
66
11
 
67
- Dir.chdir File.join(root_dir, 'test') do
68
- parts = 'workdir/checkout/rails_app/vendor/plugins/foreign_key_migrations/lib/red_hill_consulting/foreign_key_migrations/active_record/connection_adapters/.svn/text-base/table_definition.rb.svn-base'.split('/')
69
- if File.exists? File.join(*parts)
70
- Dir.chdir File.join(*(parts[0..-2])) do
71
- File.delete parts[-1]
72
- end
73
- end
74
- `rm -rf workdir`
75
- end
12
+ def test_checkout_with_subproject
13
+ repository = RailsAppSvnRepository.new
14
+ repository.prepare
76
15
 
16
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", "checkout")
17
+ rm_rf_ie workdir
18
+ mkdir_p workdir
19
+ Dir.chdir workdir do
20
+ source = repository.clean_url
77
21
 
78
- Dir.chdir File.join(root_dir, 'test') do
79
- `rm -rf workdir`
80
- end
81
- end
82
-
22
+ puts "About to checkout #{source}"
23
+ Ext.run "checkout", "--svn", source, 'rails_app'
83
24
 
84
- def test_checkout_with_subproject
85
- Dir.chdir File.join(root_dir, 'test') do
86
- Dir.chdir 'workdir' do
87
- `mkdir checkout`
88
- Dir.chdir 'checkout' do
89
- source = repository_dir('svn')
25
+ Dir.chdir 'rails_app' do
26
+ assert File.exists?('.svn')
90
27
 
91
- if windows?
92
- source = source.gsub(/\\/, "/")
28
+ %w(redhillonrails_core acts_as_list).each do |proj|
29
+ puts(ignore_text = `svn propget svn:ignore vendor/plugins`)
30
+ assert(ignore_text =~ /^#{proj}$/)
93
31
  end
94
- source = "file:///#{source}"
95
-
96
32
 
97
- puts "About to checkout #{source}"
98
- Ext.run "checkout", "--svn", source, 'rails_app'
33
+ puts(ignore_text = `svn propget svn:ignore vendor`)
34
+ assert(ignore_text =~ /^rails$/)
99
35
 
100
- Dir.chdir 'rails_app' do
101
- assert File.exists?('.svn')
36
+ %w(redhillonrails_core acts_as_list engines).each do |proj|
37
+ assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
38
+ end
102
39
 
103
- %w(foreign_key_migrations redhillonrails_core acts_as_list).each do |proj|
104
- puts(ignore_text = `svn propget svn:ignore vendor/plugins`)
105
- assert(ignore_text =~ /^#{proj}$/)
106
- end
40
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
107
41
 
108
- puts(ignore_text = `svn propget svn:ignore vendor`)
109
- assert(ignore_text =~ /^rails$/)
42
+ assert File.exists?(File.join('vendor', 'rails', '.git'))
110
43
 
111
- %w(foreign_key_migrations redhillonrails_core acts_as_list engines).each do |proj|
112
- assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
44
+ Dir.chdir File.join('vendor', 'rails') do
45
+ heads = File.readlines("heads").map(&:strip)
46
+ assert_equal 3, heads.size
47
+ heads.each do |head|
48
+ assert head =~ /^[0-9a-f]{40}$/
113
49
  end
114
50
 
115
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
116
-
117
- assert File.exists?(File.join('vendor', 'rails', '.git'))
51
+ assert `git show #{heads[0]}` =~
52
+ /^\s*commit\s+#{heads[0]}\s*$/
53
+ end
118
54
 
119
- assert File.exists?(File.join('modules', 'modules.txt'))
55
+ assert File.exists?(File.join('modules', 'modules.txt'))
120
56
 
121
- assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
57
+ assert File.read(File.join('modules', 'modules.txt')) =~ /line1 of/
122
58
 
123
- Dir.chdir File.join('vendor','plugins','engines') do
124
- assert(`git branch -a` =~ /^\*\s*edge\s*$/)
125
- assert(`git branch -a` !~ /^\*\s*master\s*$/)
126
- end
59
+ Dir.chdir File.join('vendor', 'plugins', 'engines') do
60
+ assert(`git branch -a` =~ /^\*\s*edge\s*$/)
61
+ assert(`git branch -a` !~ /^\*\s*master\s*$/)
127
62
  end
128
63
  end
129
64
  end
130
65
  end
131
- end
132
66
 
133
- def test_update_with_missing_subproject_git
134
- Dir.chdir File.join(root_dir, 'test') do
135
- Dir.chdir 'workdir' do
136
- `mkdir update`
137
- Dir.chdir 'update' do
138
- source = repository_dir('svn')
67
+ def test_update_with_missing_subproject_git
68
+ repository = RailsAppSvnRepository.new
69
+ repository.prepare
139
70
 
140
- if windows?
141
- source = source.gsub(/\\/, "/")
142
- end
143
- source = "file:///#{source}"
71
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", "checkout")
72
+ rm_rf_ie workdir
73
+ mkdir_p workdir
74
+ Dir.chdir workdir do
75
+ source = repository.clean_url
144
76
 
77
+ puts "About to checkout #{source}"
78
+ Ext.run "checkout", "--svn", source, 'rails_app'
145
79
 
146
- puts "About to checkout #{source}"
147
- Ext.run "checkout", "--svn", source, 'rails_app'
80
+ Dir.chdir 'rails_app' do
81
+ pretests = proc do
82
+ assert File.exists?('.svn')
83
+ assert !File.exists?(File.join('vendor', 'plugins', 'ssl_requirement', 'lib'))
84
+ assert File.read(".externals") =~ /rails/
85
+ assert File.read(".externals") !~ /ssl_requirement/
86
+ end
148
87
 
149
- Dir.chdir 'rails_app' do
150
- pretests = proc do
151
- assert File.exists?('.svn')
152
- assert !File.exists?(File.join('vendor', 'plugins', 'ssl_requirement', 'lib'))
153
- assert File.read(".externals") =~ /rails/
154
- assert File.read(".externals") !~ /ssl_requirement/
155
- end
88
+ pretests.call
156
89
 
157
- pretests.call
90
+ #add a project
91
+ workdir2 = File.join("workdir2")
92
+ rm_rf_ie workdir2
93
+ mkdir_p workdir2
158
94
 
159
- #add a project
160
- Dir.chdir File.join(root_dir, 'test') do
161
- Dir.chdir File.join('workdir', "rails_app") do
162
- #install a new project
163
- Ext.run "install", File.join(root_dir, 'test', 'cleanreps', 'ssl_requirement.git')
95
+ Dir.chdir workdir2 do
96
+ puts "About to checkout #{source}"
97
+ Ext.run "checkout", "--svn", source, 'rails_app'
164
98
 
165
- SvnProject.add_all
99
+ Dir.chdir "rails_app" do
100
+ #install a new project
101
+ subproject = GitRepositoryFromInternet.new("ssl_requirement.git")
102
+ Ext.run "install", subproject.clean_dir
166
103
 
167
- puts `svn commit -m "added another subproject (ssl_requirement)"`
168
- end
104
+ SvnProject.add_all
105
+
106
+ repository.mark_dirty
107
+ puts `svn commit -m "added another subproject (ssl_requirement)"`
169
108
  end
109
+ end
170
110
 
171
- pretests.call
111
+ pretests.call
172
112
 
173
- #update the project and make sure ssl_requirement was added and checked out
174
- Ext.run "update"
175
- assert File.read(".externals") =~ /ssl_requirement/
176
- assert File.exists?(File.join('vendor', 'plugins', 'ssl_requirement', 'lib'))
177
- end
113
+ #update the project and make sure ssl_requirement was added and checked out
114
+ Ext.run "update"
115
+ assert File.read(".externals") =~ /ssl_requirement/
116
+ assert File.exists?(File.join('vendor', 'plugins', 'ssl_requirement', 'lib'))
178
117
  end
179
118
  end
180
119
  end
181
- end
182
120
 
183
- def test_update_with_missing_subproject_by_revision_git
184
- subproject = "ssl_requirement"
185
- revision = "aa2dded823f8a9b378c22ba0159971508918928a"
121
+ def test_update_with_missing_subproject_by_revision_git
122
+ repository = RailsAppSvnRepository.new
123
+ repository.prepare
124
+ subproject = GitRepositoryFromInternet.new("ssl_requirement.git")
125
+ subproject.prepare
126
+ revision = "aa2dded823f8a9b378c22ba0159971508918928a"
127
+ subproject_name = subproject.name.gsub(".git", "")
128
+
129
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", "checkout")
130
+ rm_rf_ie workdir
131
+ mkdir_p workdir
132
+ Dir.chdir workdir do
133
+ source = repository.clean_url
134
+
135
+ puts "About to checkout #{source}"
136
+ Ext.run "checkout", "--svn", source, 'rails_app'
186
137
 
187
- Dir.chdir File.join(root_dir, 'test') do
188
- Dir.chdir 'workdir' do
189
- `mkdir update`
190
- Dir.chdir 'update' do
191
- source = repository_dir('svn')
138
+ Dir.chdir 'rails_app' do
192
139
 
193
- if windows?
194
- source = source.gsub(/\\/, "/")
140
+ pretests = proc do
141
+ assert File.exists?('.svn')
142
+ assert !File.exists?(File.join('vendor', 'plugins', subproject_name, 'lib'))
143
+ assert File.read(".externals") =~ /rails/
144
+ assert File.read(".externals") !~ /#{subproject}/
195
145
  end
196
- source = "file:///#{source}"
197
146
 
147
+ pretests.call
198
148
 
199
- puts "About to checkout #{source}"
200
- Ext.run "checkout", "--svn", source, 'rails_app'
149
+ #add a project
150
+ workdir2 = "workdir2"
151
+ rm_rf_ie workdir2
152
+ mkdir_p workdir2
201
153
 
202
- Dir.chdir 'rails_app' do
203
- pretests = proc do
204
- assert File.exists?('.svn')
205
- assert !File.exists?(File.join('vendor', 'plugins', subproject, 'lib'))
206
- assert File.read(".externals") =~ /rails/
207
- assert File.read(".externals") !~ /#{subproject}/
208
- end
154
+ Dir.chdir workdir2 do
209
155
 
210
- pretests.call
156
+ #install a new project
157
+ puts "About to checkout #{source}"
158
+ Ext.run "checkout", "--svn", source, 'rails_app'
211
159
 
212
- #add a project
213
- Dir.chdir File.join(root_dir, 'test') do
214
- Dir.chdir File.join('workdir', "rails_app") do
215
- #install a new project
216
- Ext.run "install", File.join(root_dir, 'test', 'cleanreps', "#{subproject}.git")
217
- Dir.chdir File.join("vendor",'plugins', subproject) do
218
- assert `git show HEAD` !~ /^\s*commit\s*#{revision}\s*$/i
219
- end
220
- #freeze it to a revision
221
- Ext.run "freeze", subproject, revision
222
- Dir.chdir File.join("vendor",'plugins', subproject) do
223
- regex = /^\s*commit\s*#{revision}\s*$/i
224
- output = `git show HEAD`
225
- result = output =~ regex
226
- unless result
227
- puts "Expecting output to match #{regex} but it was: #{output}"
228
- end
229
- assert result
160
+ Dir.chdir "rails_app" do
161
+ Ext.run "install", subproject.clean_dir
162
+
163
+ Dir.chdir File.join("vendor", 'plugins', subproject_name) do
164
+ assert `git show HEAD` !~ /^\s*commit\s*#{revision}\s*$/i
165
+ end
166
+ #freeze it to a revision
167
+ Ext.run "freeze", subproject_name, revision
168
+ Dir.chdir File.join("vendor", 'plugins', subproject_name) do
169
+ regex = /^\s*commit\s*#{revision}\s*$/i
170
+ output = `git show HEAD`
171
+ result = output =~ regex
172
+ unless result
173
+ puts "Expecting output to match #{regex} but it was: #{output}"
230
174
  end
175
+ assert result
176
+ end
231
177
 
232
- SvnProject.add_all
178
+ SvnProject.add_all
233
179
 
234
- puts `svn commit -m "added another subproject (#{subproject}) frozen to #{revision}"`
235
- end
180
+ repository.mark_dirty
181
+ puts `svn commit -m "added another subproject (#{subproject}) frozen to #{revision}"`
236
182
  end
183
+ end
237
184
 
238
- pretests.call
185
+ pretests.call
239
186
 
240
- #update the project and make sure ssl_requirement was added and checked out at the right revision
241
- Ext.run "update"
242
- assert File.read(".externals") =~ /ssl_requirement/
187
+ #update the project and make sure ssl_requirement was added and checked out at the right revision
188
+ Ext.run "update"
189
+ assert File.read(".externals") =~ /ssl_requirement/
243
190
 
244
- assert File.exists?(File.join('vendor', 'plugins', subproject, 'lib'))
191
+ assert File.exists?(File.join('vendor', 'plugins', subproject_name, 'lib'))
245
192
 
246
- Dir.chdir File.join("vendor",'plugins', subproject) do
247
- assert `git show HEAD` =~ /^\s*commit\s*#{revision}\s*$/i
248
- end
193
+ Dir.chdir File.join("vendor",'plugins', subproject_name) do
194
+ assert `git show HEAD` =~ /^\s*commit\s*#{revision}\s*$/i
249
195
  end
250
196
  end
251
197
  end
252
198
  end
253
- end
254
199
 
255
- def test_update_with_missing_subproject_svn
256
- Dir.chdir File.join(root_dir, 'test') do
257
- Dir.chdir 'workdir' do
258
- `mkdir update`
259
- Dir.chdir 'update' do
260
- source = repository_dir('svn')
200
+ def test_update_with_missing_subproject_svn
201
+ repository = RailsAppSvnRepository.new
202
+ repository.prepare
203
+ subproject = SvnRepositoryFromDump.new("empty_plugin")
204
+ subproject.prepare
261
205
 
262
- if windows?
263
- source = source.gsub(/\\/, "/")
264
- end
265
- source = "file:///#{source}"
206
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", "checkout")
207
+ rm_rf_ie workdir
208
+ mkdir_p workdir
209
+ Dir.chdir workdir do
210
+ source = repository.clean_url
266
211
 
212
+ puts "About to checkout #{source}"
213
+ Ext.run "checkout", "--svn", source, 'rails_app'
267
214
 
268
- puts "About to checkout #{source}"
269
- Ext.run "checkout", "--svn", source, 'rails_app'
215
+ Dir.chdir 'rails_app' do
216
+ pretests = proc do
217
+ assert File.exists?('.svn')
218
+ assert !File.exists?(File.join('vendor', 'plugins', subproject.name, 'lib'))
219
+ assert File.read(".externals") =~ /rails/
220
+ assert File.read(".externals") !~ /empty_plugin/
221
+ end
270
222
 
271
- Dir.chdir 'rails_app' do
272
- pretests = proc do
273
- assert File.exists?('.svn')
274
- assert !File.exists?(File.join('vendor', 'plugins', 'empty_plugin', 'lib'))
275
- assert File.read(".externals") =~ /rails/
276
- assert File.read(".externals") !~ /empty_plugin/
277
- end
223
+ pretests.call
278
224
 
279
- pretests.call
225
+ #add a project
226
+ workdir2 = File.join "workdir2", "svn"
227
+ rm_rf_ie workdir2
228
+ mkdir_p workdir2
280
229
 
281
- #add a project
282
- Dir.chdir File.join(root_dir, 'test') do
283
- Dir.chdir File.join('workdir', "rails_app") do
284
- #install a new project
285
- Ext.run "install", "--svn", "file:///#{File.join(root_dir, 'test', 'cleanreps', 'empty_plugin')}"
230
+ Dir.chdir workdir2 do
231
+ puts "About to checkout #{source}"
232
+ Ext.run "checkout", "--svn", source, 'rails_app'
286
233
 
287
- SvnProject.add_all
234
+ Dir.chdir 'rails_app' do
235
+ #install a new project
236
+ Ext.run "install", "--svn", subproject.clean_url
288
237
 
289
- puts `svn commit -m "added another subproject (empty_plugin)"`
290
- end
238
+ SvnProject.add_all
239
+
240
+ repository.mark_dirty
241
+ puts `svn commit -m "added another subproject (#{subproject.name})"`
291
242
  end
243
+ end
292
244
 
293
- pretests.call
245
+ pretests.call
294
246
 
295
- #update the project and make sure ssl_requirement was added and checked out
296
- Ext.run "update"
297
- assert File.read(".externals") =~ /empty_plugin/
298
- assert File.exists?(File.join('vendor', 'plugins', 'empty_plugin', 'lib'))
299
- end
247
+ #update the project and make sure ssl_requirement was added and checked out
248
+ Ext.run "update"
249
+ assert File.read(".externals") =~ /empty_plugin/
250
+ assert File.exists?(File.join('vendor', 'plugins', subproject.name, 'lib'))
300
251
  end
301
252
  end
302
253
  end
303
- end
304
-
305
- def test_export_with_subproject
306
- Dir.chdir File.join(root_dir, 'test') do
307
- Dir.chdir 'workdir' do
308
- `mkdir export`
309
- Dir.chdir 'export' do
310
- source = repository_dir('svn')
311
-
312
- if windows?
313
- source.gsub!(/\\/, "/")
314
- end
315
- source = "file:///#{source}"
316
254
 
255
+ def test_export_with_subproject
256
+ repository = RailsAppSvnRepository.new
257
+ repository.prepare
317
258
 
318
- puts "About to export #{source}"
319
- Ext.run "export", "--svn", source, 'rails_app'
259
+ workdir = File.join(root_dir, 'test', "tmp", "workdir", "export")
260
+ rm_rf_ie workdir
261
+ mkdir_p workdir
262
+ Dir.chdir workdir do
263
+ source = repository.clean_url
320
264
 
321
- Dir.chdir 'rails_app' do
322
- assert File.exists?('.svn')
323
-
324
- %w(foreign_key_migrations redhillonrails_core acts_as_list).each do |proj|
325
- puts(ignore_text = `svn propget svn:ignore vendor/plugins`)
326
- assert(ignore_text =~ /^#{proj}$/)
327
- end
265
+ puts "About to export #{source}"
266
+ Ext.run "export", "--svn", source, 'rails_app'
328
267
 
329
- puts(ignore_text = `svn propget svn:ignore vendor`)
330
- assert(ignore_text =~ /^rails$/)
268
+ Dir.chdir 'rails_app' do
269
+ assert !File.exists?('.svn')
331
270
 
332
- Dir.chdir File.join('vendor', 'rails') do
333
- #can't check this if it's local. It seems --depth 1 is ignored for
334
- #repositories on the local machine.
335
- #assert `git show 92f944818eece9fe4bc62ffb39accdb71ebc32be` !~ /azimux/
271
+ Dir.chdir File.join('vendor', 'rails') do
272
+ heads = File.readlines("heads").map(&:strip)
273
+ assert_equal 3, heads.size
274
+ heads.each do |head|
275
+ assert head =~ /^[0-9a-f]{40}$/
336
276
  end
337
277
 
338
- %w(foreign_key_migrations redhillonrails_core acts_as_list).each do |proj|
339
- puts "filethere? #{proj}: #{File.exists?(File.join('vendor', 'plugins', proj, 'lib'))}"
340
- if !File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
341
- puts "here"
342
- end
343
- assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
344
- end
278
+ assert `git show #{heads[0]}` !~
279
+ /^\s*commit\s+#{heads[0]}\s*$/
280
+ end
345
281
 
346
- %w(foreign_key_migrations redhillonrails_core).each do |proj|
347
- assert !File.exists?(File.join('vendor', 'plugins',proj, '.svn'))
282
+ %w(redhillonrails_core acts_as_list).each do |proj|
283
+ puts "filethere? #{proj}: #{File.exists?(File.join('vendor', 'plugins', proj, 'lib'))}"
284
+ if !File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
285
+ puts "here"
348
286
  end
287
+ assert File.exists?(File.join('vendor', 'plugins', proj, 'lib'))
288
+ end
349
289
 
350
- assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
290
+ %w(redhillonrails_core).each do |proj|
291
+ assert !File.exists?(File.join('vendor', 'plugins',proj, '.svn'))
351
292
  end
293
+
294
+ assert File.exists?(File.join('vendor', 'rails', 'activerecord', 'lib'))
352
295
  end
353
296
  end
354
297
  end
355
- end
356
298
 
357
- def test_uninstall
358
- Dir.chdir File.join(root_dir, 'test') do
359
- Dir.chdir 'workdir' do
360
- `mkdir checkout`
361
- Dir.chdir 'checkout' do
362
- #source = File.join(root_dir, 'test', 'workdir', 'rails_app')
363
- source = repository_dir('svn')
364
-
365
- if windows?
366
- source = source.gsub(/\\/, "/")
367
- #source.gsub!(/^[A-Z]:[\/\\]/, "")
368
- end
369
- source = "file:///#{source}"
299
+ def test_uninstall
300
+ return
301
+ Dir.chdir File.join(root_dir, 'test') do
302
+ Dir.chdir 'workdir' do
303
+ `mkdir checkout`
304
+ Dir.chdir 'checkout' do
305
+ #source = File.join(root_dir, 'test', 'workdir', 'rails_app')
306
+ source = repository_dir('svn')
307
+
308
+ if windows?
309
+ source = source.gsub(/\\/, "/")
310
+ #source.gsub!(/^[A-Z]:[\/\\]/, "")
311
+ end
312
+ source = "file:///#{source}"
370
313
 
371
- puts "About to checkout #{source}"
372
- Ext.run "checkout", "--svn", source, "rails_app"
314
+ puts "About to checkout #{source}"
315
+ Ext.run "checkout", "--svn", source, "rails_app"
373
316
 
374
- Dir.chdir 'rails_app' do
375
- mp = Ext.new.main_project
317
+ Dir.chdir 'rails_app' do
318
+ mp = Ext.new.main_project
376
319
 
377
- projs = %w(foreign_key_migrations redhillonrails_core acts_as_list)
378
- projs_i = projs.dup
379
- projs_ni = []
320
+ projs = %w(foreign_key_migrations redhillonrails_core acts_as_list)
321
+ projs_i = projs.dup
322
+ projs_ni = []
380
323
 
381
- #let's uninstall acts_as_list
382
- Ext.run "uninstall", "acts_as_list"
324
+ #let's uninstall acts_as_list
325
+ Ext.run "uninstall", "acts_as_list"
383
326
 
384
- projs_ni << projs_i.delete('acts_as_list')
327
+ projs_ni << projs_i.delete('acts_as_list')
385
328
 
386
- mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, [], projs_i, projs_ni
329
+ mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, [], projs_i, projs_ni
387
330
 
388
- Ext.run "uninstall", "-f", "foreign_key_migrations"
331
+ Ext.run "uninstall", "-f", "foreign_key_migrations"
389
332
 
390
- projs_ni << projs_i.delete('foreign_key_migrations')
333
+ projs_ni << projs_i.delete('foreign_key_migrations')
391
334
 
392
- projs_dne = []
393
- projs_dne << projs.delete('foreign_key_migrations')
335
+ projs_dne = []
336
+ projs_dne << projs.delete('foreign_key_migrations')
394
337
 
395
- mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, projs_dne, projs_i, projs_ni
338
+ mp.assert_e_dne_i_ni proc{|a|assert(a)}, projs, projs_dne, projs_i, projs_ni
339
+ end
396
340
  end
397
341
  end
398
342
  end
399
343
  end
344
+
400
345
  end
401
346
  end
402
347
  end