ext 1.0.7 → 1.1.0

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 (37) hide show
  1. data/CHANGELOG +3 -0
  2. data/README +12 -12
  3. data/Rakefile +1 -1
  4. data/lib/externals/ext.rb +35 -43
  5. data/test/test_checkout_git.rb +3 -3
  6. data/test/test_checkout_with_subprojects_git.rb +3 -3
  7. data/test/test_checkout_with_subprojects_svn.rb +3 -3
  8. data/test/test_file_utils_extensions.rb +2 -2
  9. data/test/test_freeze_to_revision.rb +37 -5
  10. data/test/test_git_project_extract_name.rb +2 -2
  11. data/test/test_init_git.rb +3 -3
  12. data/test/test_out_of_date_git_subproject.rb +3 -3
  13. data/test/test_projects.rb +2 -2
  14. data/test/test_rails_detection.rb +3 -3
  15. data/test/test_string_extensions.rb +2 -2
  16. data/test/test_svn_branches.rb +3 -3
  17. data/test/test_touch_emptydirs.rb +2 -2
  18. data/test/test_version.rb +2 -2
  19. metadata +4 -22
  20. data/lib/externals/test/basic_git_repository.rb +0 -57
  21. data/lib/externals/test/engines.rb +0 -11
  22. data/lib/externals/test/engines_with_branch1.rb +0 -36
  23. data/lib/externals/test/fake_rails_repository.rb +0 -112
  24. data/lib/externals/test/git_repository.rb +0 -15
  25. data/lib/externals/test/git_repository_from_internet.rb +0 -20
  26. data/lib/externals/test/modules_svn_branches_repository.rb +0 -72
  27. data/lib/externals/test/modules_svn_repository.rb +0 -41
  28. data/lib/externals/test/rails_app_git_branches.rb +0 -109
  29. data/lib/externals/test/rails_app_git_repository.rb +0 -66
  30. data/lib/externals/test/rails_app_svn_branches.rb +0 -132
  31. data/lib/externals/test/rails_app_svn_repository.rb +0 -106
  32. data/lib/externals/test/rails_app_unmanaged.rb +0 -25
  33. data/lib/externals/test/repository.rb +0 -186
  34. data/lib/externals/test/simple_git_with_sub.rb +0 -72
  35. data/lib/externals/test/svn_repository_from_dump.rb +0 -27
  36. data/lib/externals/test/svn_repository_helper.rb +0 -10
  37. data/lib/externals/test_case.rb +0 -54
@@ -1,25 +0,0 @@
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
@@ -1,186 +0,0 @@
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
- raise "hmmm... too scared to delete #{clean_dir}" unless clean_dir =~ /[\/\\]test[\/\\]tmp[\/\\]/
133
- rm_rf_ie clean_dir
134
- end
135
-
136
- def delete_pristine_dir
137
- raise "hmmm... too scared to delete #{pristine_dir}" unless clean_dir =~ /[\/\\]test[\/\\]tmp[\/\\]/
138
- rm_rf_ie pristine_dir
139
- end
140
-
141
- def dirty?
142
- Dir.chdir clean_dir_parent do
143
- File.exists? working_file_name
144
- end
145
- end
146
-
147
- def mark_dirty
148
- Dir.chdir clean_dir_parent do
149
- File.open working_file_name, "w" do |file|
150
- file.puts "dirty"
151
- end
152
- end
153
- end
154
-
155
- def unmark_dirty
156
- Dir.chdir clean_dir_parent do
157
- File.delete working_file_name
158
- end
159
- end
160
-
161
- def pristine_dirty?
162
- Dir.chdir pristine_dir_parent do
163
- File.exists? working_file_name
164
- end
165
- end
166
-
167
- def pristine_mark_dirty
168
- Dir.chdir pristine_dir_parent do
169
- File.open working_file_name, "w" do |file|
170
- file.puts "dirty"
171
- end
172
- end
173
- end
174
-
175
- def pristine_unmark_dirty
176
- Dir.chdir pristine_dir_parent do
177
- File.delete working_file_name
178
- end
179
- end
180
-
181
- def working_file_name
182
- ".working_#{name}"
183
- end
184
- end
185
- end
186
- end
@@ -1,72 +0,0 @@
1
- require 'externals/test/git_repository'
2
- require 'externals/test/basic_git_repository'
3
-
4
- module Externals
5
- module Test
6
- class SimpleGitWithSub < GitRepository
7
- def initialize
8
- super "simple_wth_sub", File.join("git", "5")
9
- dependents.merge!(
10
- :basic => BasicGitRepository.new
11
- )
12
- end
13
-
14
- def build_here
15
- mkdir "#{name}.git"
16
- Dir.chdir "#{name}.git" do
17
- `git init --bare`
18
- raise unless $? == 0
19
- end
20
-
21
- mkdir "#{name}.working"
22
-
23
- Dir.chdir("#{name}.working") do
24
- `git init`
25
- raise unless $? == 0
26
-
27
- open 'simple_readme.txt', 'w' do |f|
28
- f.write "simple_readme.txt Line 1
29
- Line 2
30
- Line 3
31
- "
32
- end
33
-
34
- `git add .`
35
- raise unless $? == 0
36
- `git commit -m "added simple_readme.txt"`
37
- raise unless $? == 0
38
-
39
- open 'simple_readme.txt', 'a' do |f|
40
- f.write "line 4"
41
- end
42
-
43
- `git add .`
44
- raise unless $? == 0
45
- `git commit -m "added a line to simple_readme.txt"`
46
- raise unless $? == 0
47
-
48
- # initialize externals
49
- Ext.run "init"
50
-
51
- mkdir "subs"
52
-
53
- Ext.run "touch_emptydirs"
54
-
55
- # adding a branch here exposes a bug
56
- Ext.run "install", "-g", "-b", "master",
57
- dependents[:basic].clean_dir, "subs/#{dependents[:basic].name}"
58
-
59
- `git add .`
60
- raise unless $? == 0
61
- `git commit -m "added basic subproject under subs"`
62
- raise unless $? == 0
63
- `git push ../#{name}.git HEAD:master`
64
- raise unless $? == 0
65
- end
66
-
67
- rm_rf "#{name}.working"
68
- end
69
-
70
- end
71
- end
72
- end
@@ -1,27 +0,0 @@
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
@@ -1,10 +0,0 @@
1
- module Externals
2
- module Test
3
- module SvnRepositoryHelper
4
- def clean_url
5
- url = File.join 'file:///', clean_dir
6
- url.gsub(/^\s*file:(\/*)/, "file:///")
7
- end
8
- end
9
- end
10
- end
@@ -1,54 +0,0 @@
1
- require 'test/unit'
2
- require 'fileutils'
3
-
4
- module Externals
5
- TestCase = Test::Unit::TestCase
6
- module ExtTestCase
7
- include FileUtils
8
-
9
- protected
10
-
11
- def mark_dirty file
12
- File.open working_file_name(file), "w" do |file|
13
- file.puts "dirty"
14
- end
15
- end
16
-
17
- def unmark_dirty file
18
- File.delete working_file_name(file)
19
- end
20
-
21
- def working_file_name file
22
- ".working_#{file}"
23
- end
24
-
25
- def dirty?(file)
26
- File.exists? working_file_name(file)
27
- end
28
-
29
- def delete_if_dirty file
30
- if File.exists? file
31
- if dirty?(file)
32
- rm_rf file
33
- end
34
- end
35
- end
36
-
37
- def rails_version
38
- /[\d\.]+/.match(`#{rails_exe} --version`)[0]
39
- end
40
-
41
- def rails_exe
42
- "jruby -S rails"
43
- "rails"
44
- end
45
-
46
- def windows?
47
- ENV['OS'] =~ /^Win/i
48
- end
49
-
50
- def root_dir
51
- File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
52
- end
53
- end
54
- end