ext 0.1.8 → 1.0.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.
- data/CHANGELOG +9 -2
- data/README +44 -0
- data/lib/externals/ext.rb +12 -4
- data/lib/externals/project.rb +111 -5
- data/lib/externals/scms/git_project.rb +27 -15
- data/lib/externals/scms/svn_project.rb +35 -20
- data/lib/externals/test_case.rb +8 -3
- data/test/test_checkout_git.rb +6 -6
- data/test/test_checkout_with_subprojects_svn.rb +7 -1
- data/test/test_projects.rb +136 -0
- metadata +6 -12
data/CHANGELOG
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
-
|
1
|
+
March 29, 20011 Version 1.0.0 released
|
2
|
+
- Added scm_opts and <scm_name>_opts .externals file options with
|
3
|
+
(_co|_ex|_st|_up) suffixed versions for passing options to the underlying
|
4
|
+
SCM executable.
|
5
|
+
- Some fixes to issues like recognizing svn URLs (thanks to Lane Roathe) and
|
6
|
+
jruby testing
|
7
|
+
|
8
|
+
February 17, 2011 Version 0.1.8 released
|
2
9
|
- Fixes a compatibility issue with jruby (thanks to Patrik Sundberg)
|
3
10
|
- Fixes some issues with recognizing rails 3 projects and testing with
|
4
11
|
rails 3 installed
|
5
12
|
|
6
|
-
1/3/2010 Version 1.6 released
|
13
|
+
1/3/2010 Version 0.1.6 released
|
7
14
|
- Fixes a problem that can occur if ext is symlinked (thanks to Olmo Maldonado)
|
8
15
|
- Added --version command line option
|
9
16
|
- Fixes a problem with parsing project names from git repository URLs
|
data/README
CHANGED
@@ -126,6 +126,50 @@ st Like status, but skips the main project.
|
|
126
126
|
|
127
127
|
up Like update, but skips the main project.
|
128
128
|
|
129
|
+
|
130
|
+
PASSING OPTIONS TO THE UNDERLYING SCM
|
131
|
+
-------------------------------------
|
132
|
+
Sometimes it's convenient to have options passed to the underlying scm
|
133
|
+
executable, like --trust-certid to svn, etc. This can be done by editing the
|
134
|
+
.externals file. You can put scm_opts = <options> under the project you want,
|
135
|
+
and it will be passed whenever externals calls the executable. You can specify
|
136
|
+
an option to only be ran when doing co/ex/st/up by adding _co/_ex/_st/_up to
|
137
|
+
the scm_opts option.
|
138
|
+
|
139
|
+
EXAMPLE:
|
140
|
+
|
141
|
+
[.]
|
142
|
+
scm = git
|
143
|
+
scm_opts = --verbose
|
144
|
+
|
145
|
+
[vendor/plugins/some_plugin]
|
146
|
+
scm = svn
|
147
|
+
scm_opts = --trust-certid
|
148
|
+
scm_opts_co = --non-interactive
|
149
|
+
|
150
|
+
This type of a .externals file tells externals to pass
|
151
|
+
" --non-interactive --trust-certid" to svn when doing a checkout of some_plugin.
|
152
|
+
"--trust-certid" will be sent to all other calls to svn dealing with
|
153
|
+
some_plugin. "--verbose" will be passed to git on all calls dealing with the
|
154
|
+
main project.
|
155
|
+
|
156
|
+
You can pass options globally by setting <scm_name>_opts in the main project.
|
157
|
+
|
158
|
+
EXAMPLE:
|
159
|
+
|
160
|
+
[.]
|
161
|
+
scm = svn
|
162
|
+
svn_opts = --trust-certid
|
163
|
+
svn_opts_co = --non-interactive
|
164
|
+
|
165
|
+
[vendor/plugins/some_plugin]
|
166
|
+
scm = svn
|
167
|
+
|
168
|
+
This will pass "--non-interactive --trust-certid" to all co calls dealing with
|
169
|
+
subversion projects, regardless of which project it is.
|
170
|
+
|
171
|
+
|
172
|
+
|
129
173
|
The externals project is copyright 2008 by Miles Georgi, nopugs.com, azimux.com
|
130
174
|
and is released under the MIT license.
|
131
175
|
|
data/lib/externals/ext.rb
CHANGED
@@ -10,7 +10,7 @@ module Externals
|
|
10
10
|
#exit status
|
11
11
|
OBSOLETE_EXTERNALS_FILE = 15
|
12
12
|
|
13
|
-
VERSION = '0.
|
13
|
+
VERSION = '1.0.0'
|
14
14
|
PROJECT_TYPES_DIRECTORY = File.join(File.dirname(__FILE__), '..', 'externals','project_types')
|
15
15
|
|
16
16
|
# Full commands operate on the main project as well as the externals
|
@@ -250,12 +250,16 @@ module Externals
|
|
250
250
|
end
|
251
251
|
|
252
252
|
def projects
|
253
|
-
|
253
|
+
return @projects if @projects
|
254
|
+
@projects = []
|
254
255
|
configuration.sections.each do |section|
|
255
|
-
|
256
|
+
@projects << Ext.project_class(section[:scm]||infer_scm(section[:repository])).new(
|
256
257
|
section.attributes.merge(:path => section.title))
|
257
258
|
end
|
258
|
-
|
259
|
+
#let's set the parents of these projects
|
260
|
+
main = main_project
|
261
|
+
subprojects.each {|subproject| subproject.parent = main}
|
262
|
+
@projects
|
259
263
|
end
|
260
264
|
|
261
265
|
def subproject_by_name_or_path name
|
@@ -295,6 +299,7 @@ module Externals
|
|
295
299
|
|
296
300
|
def reload_configuration
|
297
301
|
@configuration = nil
|
302
|
+
@projects = nil
|
298
303
|
configuration
|
299
304
|
end
|
300
305
|
|
@@ -427,6 +432,7 @@ Please use
|
|
427
432
|
end
|
428
433
|
section[:revision] = revision
|
429
434
|
configuration.write '.externals'
|
435
|
+
reload_configuration
|
430
436
|
|
431
437
|
subproject_by_name_or_path(args[0]).up
|
432
438
|
end
|
@@ -483,6 +489,7 @@ that you are installing. Use an option to specify it
|
|
483
489
|
|
484
490
|
configuration.remove_section(project.path)
|
485
491
|
configuration.write '.externals'
|
492
|
+
reload_configuration
|
486
493
|
|
487
494
|
if options[:force_removal]
|
488
495
|
Dir.chdir File.dirname(project.path) do
|
@@ -717,6 +724,7 @@ Please use the --type option to tell ext which to use."
|
|
717
724
|
end
|
718
725
|
|
719
726
|
config.write('.externals')
|
727
|
+
reload_configuration
|
720
728
|
end
|
721
729
|
|
722
730
|
def version(args, options)
|
data/lib/externals/project.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
require 'externals/extensions/symbol'
|
2
2
|
|
3
3
|
module Externals
|
4
|
-
|
5
|
-
|
4
|
+
OPTS_SUFFIXES = ["co", "up", "st", "ex"] unless const_defined?('OPTS_SUFFIXES')
|
5
|
+
VALID_ATTRIB = ([
|
6
|
+
:name, :path, :repository, :branch, :type, :scm, :revision
|
7
|
+
]
|
8
|
+
).map(&:to_s) unless const_defined?('VALID_ATTRIB')
|
6
9
|
|
7
10
|
class Project
|
11
|
+
attr_accessor :parent
|
12
|
+
|
8
13
|
def self.attr_attr_accessor *names
|
9
14
|
names = [names].flatten
|
10
15
|
names.each do |name|
|
@@ -55,10 +60,15 @@ module Externals
|
|
55
60
|
new_hash
|
56
61
|
end
|
57
62
|
|
58
|
-
|
63
|
+
invalid_attrib = hash.keys - Externals::VALID_ATTRIB
|
59
64
|
|
60
|
-
if !
|
61
|
-
|
65
|
+
if !invalid_attrib.empty?
|
66
|
+
invalid_attrib.reject! do |attribute|
|
67
|
+
attribute =~ /^\w+_opts(_(#{OPTS_SUFFIXES.join("|")}))?/
|
68
|
+
end
|
69
|
+
if !invalid_attrib.empty?
|
70
|
+
raise "invalid attribute(s): #{invalid_attrib.join(', ')}"
|
71
|
+
end
|
62
72
|
end
|
63
73
|
|
64
74
|
path = hash.delete('path')
|
@@ -129,6 +139,96 @@ module Externals
|
|
129
139
|
end
|
130
140
|
end
|
131
141
|
|
142
|
+
def scm_opts
|
143
|
+
values = [
|
144
|
+
attributes[:scm_opts],
|
145
|
+
send("#{scm}_opts")
|
146
|
+
].compact
|
147
|
+
|
148
|
+
if !values.empty?
|
149
|
+
values.join(" ")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def scm_opts= value
|
154
|
+
attributes[:scm_opts] = value
|
155
|
+
end
|
156
|
+
|
157
|
+
# create the suffixed versions
|
158
|
+
OPTS_SUFFIXES.map do |suffix|
|
159
|
+
name = "scm_opts_#{suffix}"
|
160
|
+
end.each do |name|
|
161
|
+
define_method name do
|
162
|
+
values = [
|
163
|
+
attributes[name.to_sym],
|
164
|
+
attributes[:scm_opts],
|
165
|
+
send(name.gsub(/^scm/, scm))
|
166
|
+
].compact
|
167
|
+
|
168
|
+
if !values.empty?
|
169
|
+
values.join(" ")
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
define_method "#{name}=" do |value|
|
174
|
+
attributes[name.to_sym] = value
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
def self.inherited child
|
180
|
+
#create the <scm_name>_opts_co/ex/st/up and <scm_opts>_opts setting
|
181
|
+
#such as svn_opts and svn_opts_co from the main project (stored
|
182
|
+
#in the parrent attribute.)
|
183
|
+
def child.install_scm_opts_methods
|
184
|
+
raise unless scm && scm != ""
|
185
|
+
|
186
|
+
#first we create global <scm_name>_opts accessors that will apply to all
|
187
|
+
#of the suffixed versions (<scm_name>_opts_co) as well as the project
|
188
|
+
#specific ones. (scm_opts, scm_opts_co, etc)
|
189
|
+
scm_name = scm
|
190
|
+
Project.__send__(:define_method, "#{scm_name}_opts_raw") do
|
191
|
+
attributes[name.to_sym]
|
192
|
+
end
|
193
|
+
#global settings are fetched from the parent project.
|
194
|
+
Project.__send__(:define_method, "#{scm_name}_opts") do
|
195
|
+
if parent
|
196
|
+
parent.__send__("#{scm_name}_opts")
|
197
|
+
else
|
198
|
+
attributes["#{scm_name}_opts".to_sym]
|
199
|
+
end
|
200
|
+
end
|
201
|
+
Project.__send__(:define_method, "#{scm_name}_opts=") do |value|
|
202
|
+
attributes["#{scm_name}_opts".to_sym] = value
|
203
|
+
end
|
204
|
+
|
205
|
+
#now we create the suffixed version of the global settings.
|
206
|
+
OPTS_SUFFIXES.map do |suffix|
|
207
|
+
name = "#{scm_name}_opts_#{suffix}"
|
208
|
+
end.each do |name|
|
209
|
+
#defer to the parent project for these global settings
|
210
|
+
Project.__send__(:define_method, name) do
|
211
|
+
if parent
|
212
|
+
parent.__send__(name)
|
213
|
+
else
|
214
|
+
values = [
|
215
|
+
attributes[name.to_sym],
|
216
|
+
self.send("#{scm_name}_opts")
|
217
|
+
].compact
|
218
|
+
|
219
|
+
if !values.empty?
|
220
|
+
values.join(" ")
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
Project.__send__(:define_method, "#{name}=") do |value|
|
225
|
+
attributes[name.to_sym] = value
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
132
232
|
protected
|
133
233
|
def trim_quotes value
|
134
234
|
if value
|
@@ -139,5 +239,11 @@ module Externals
|
|
139
239
|
end
|
140
240
|
end
|
141
241
|
end
|
242
|
+
|
243
|
+
#helper method for converting "co" into "scm_opts_co" and "" into "scm_opts"
|
244
|
+
def resolve_opts command = ""
|
245
|
+
command = "_#{command}" if command != ""
|
246
|
+
send("scm_opts#{command}")
|
247
|
+
end
|
142
248
|
end
|
143
249
|
end
|
@@ -3,12 +3,14 @@ require File.join(File.dirname(__FILE__), '..', 'project')
|
|
3
3
|
|
4
4
|
module Externals
|
5
5
|
class GitProject < Project
|
6
|
-
|
7
6
|
def default_branch
|
8
7
|
'master'
|
9
8
|
end
|
10
9
|
|
11
|
-
|
10
|
+
private
|
11
|
+
def co_or_up command
|
12
|
+
opts = resolve_opts(command)
|
13
|
+
|
12
14
|
puts "path is #{path} repository is #{repository}"
|
13
15
|
if path != '.'
|
14
16
|
(rmdircmd = "rmdir #{path}")
|
@@ -19,22 +21,29 @@ module Externals
|
|
19
21
|
dest = '' if dest == '.'
|
20
22
|
dest = "\"#{dest}\"" if dest && !dest.empty?
|
21
23
|
|
22
|
-
puts(gitclonecmd = "git clone \"#{repository}\" #{dest}")
|
24
|
+
puts(gitclonecmd = "git #{opts} clone \"#{repository}\" #{dest}")
|
23
25
|
puts `#{gitclonecmd}`
|
24
26
|
|
25
|
-
change_to_branch_revision
|
27
|
+
change_to_branch_revision(command)
|
28
|
+
end
|
29
|
+
|
30
|
+
public
|
31
|
+
def co *args
|
32
|
+
co_or_up "co"
|
26
33
|
end
|
27
34
|
|
28
|
-
def change_to_branch_revision
|
35
|
+
def change_to_branch_revision command = ""
|
36
|
+
opts = resolve_opts(command)
|
37
|
+
|
29
38
|
if branch
|
30
39
|
Dir.chdir path do
|
31
|
-
puts `git checkout --track -b #{branch} origin/#{branch}`
|
40
|
+
puts `git #{opts} checkout --track -b #{branch} origin/#{branch}`
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
35
44
|
if revision
|
36
45
|
Dir.chdir path do
|
37
|
-
puts `git checkout #{revision}`
|
46
|
+
puts `git #{opts} checkout #{revision}`
|
38
47
|
end
|
39
48
|
end
|
40
49
|
end
|
@@ -51,32 +60,32 @@ module Externals
|
|
51
60
|
|
52
61
|
dest = "\"#{dest}\"" if dest && !dest.empty?
|
53
62
|
|
54
|
-
puts(gitclonecmd = "git clone --depth 1 \"#{repository}\" #{dest}")
|
63
|
+
puts(gitclonecmd = "git #{scm_opts_ex} clone --depth 1 \"#{repository}\" #{dest}")
|
55
64
|
|
56
65
|
puts `#{gitclonecmd}`
|
57
66
|
|
58
|
-
change_to_branch_revision
|
67
|
+
change_to_branch_revision "ex"
|
59
68
|
end
|
60
69
|
|
61
70
|
def up *args
|
62
71
|
if File.exists? path
|
63
72
|
if revision
|
64
|
-
change_to_branch_revision
|
73
|
+
change_to_branch_revision "up"
|
65
74
|
else
|
66
75
|
puts "updating #{path}:"
|
67
76
|
Dir.chdir path do
|
68
|
-
puts `git pull`
|
77
|
+
puts `git #{scm_opts_up} pull`
|
69
78
|
end
|
70
79
|
end
|
71
80
|
else
|
72
|
-
|
81
|
+
co_or_up "up"
|
73
82
|
end
|
74
83
|
end
|
75
84
|
|
76
85
|
def st *args
|
77
86
|
puts "\nstatus for #{path}:"
|
78
87
|
Dir.chdir path do
|
79
|
-
puts `git status`
|
88
|
+
puts `git #{scm_opts_st} status`
|
80
89
|
end
|
81
90
|
end
|
82
91
|
|
@@ -94,10 +103,13 @@ module Externals
|
|
94
103
|
"git"
|
95
104
|
end
|
96
105
|
|
106
|
+
install_scm_opts_methods
|
107
|
+
|
97
108
|
def self.detected?
|
98
109
|
File.exists? ".git"
|
99
110
|
end
|
100
111
|
|
112
|
+
#this is a test helper method
|
101
113
|
def self.add_all
|
102
114
|
puts `git add .`
|
103
115
|
end
|
@@ -157,7 +169,7 @@ module Externals
|
|
157
169
|
|
158
170
|
def current_revision
|
159
171
|
Dir.chdir path do
|
160
|
-
if `git show HEAD` =~ /^\s*commit\s*([0-9a-fA-F]*)\s*$/i
|
172
|
+
if `git #{scm_opts} show HEAD` =~ /^\s*commit\s*([0-9a-fA-F]*)\s*$/i
|
161
173
|
$1
|
162
174
|
end
|
163
175
|
end
|
@@ -165,7 +177,7 @@ module Externals
|
|
165
177
|
|
166
178
|
def current_branch
|
167
179
|
Dir.chdir path do
|
168
|
-
if `git branch -a` =~ /^\s*\*\s*([^\s]*)\s*$/
|
180
|
+
if `git #{scm_opts} branch -a` =~ /^\s*\*\s*([^\s]*)\s*$/
|
169
181
|
$1
|
170
182
|
end
|
171
183
|
end
|
@@ -2,25 +2,34 @@ require File.join(File.dirname(__FILE__), '..', 'project')
|
|
2
2
|
|
3
3
|
module Externals
|
4
4
|
class SvnProject < Project
|
5
|
-
|
6
5
|
def default_branch
|
7
6
|
nil
|
8
7
|
end
|
9
8
|
|
10
|
-
|
9
|
+
private
|
10
|
+
def co_or_up command
|
11
|
+
opts = resolve_opts(command)
|
12
|
+
|
11
13
|
(rmdircmd = "rmdir #{path}")
|
12
14
|
|
13
15
|
`#{rmdircmd}` if File.exists? path
|
14
|
-
puts(svncocmd = "svn co #{repository} #{path}")
|
16
|
+
puts(svncocmd = "svn #{opts} co #{repository} #{path}")
|
15
17
|
puts `#{svncocmd}`
|
16
18
|
|
17
|
-
change_to_revision
|
19
|
+
change_to_revision command
|
20
|
+
end
|
21
|
+
|
22
|
+
public
|
23
|
+
def co *args
|
24
|
+
co_or_up "co"
|
18
25
|
end
|
19
26
|
|
20
|
-
def change_to_revision
|
27
|
+
def change_to_revision command = ""
|
28
|
+
opts = resolve_opts(command)
|
29
|
+
|
21
30
|
if revision
|
22
31
|
Dir.chdir path do
|
23
|
-
puts `svn up -r #{revision}`
|
32
|
+
puts `svn #{opts} up -r #{revision}`
|
24
33
|
end
|
25
34
|
end
|
26
35
|
end
|
@@ -35,47 +44,50 @@ module Externals
|
|
35
44
|
end
|
36
45
|
|
37
46
|
`#{rmdircmd}` if File.exists? path
|
38
|
-
puts(svncocmd = "svn export #{repository} #{path}")
|
47
|
+
puts(svncocmd = "svn #{scm_opts_ex} export #{repository} #{path}")
|
39
48
|
puts `#{svncocmd}`
|
40
49
|
end
|
41
50
|
|
42
51
|
def up *args
|
43
52
|
if File.exists? path
|
44
53
|
if revision
|
45
|
-
change_to_revision
|
54
|
+
change_to_revision "up"
|
46
55
|
else
|
47
56
|
puts "updating #{path}:"
|
48
57
|
Dir.chdir path do
|
49
|
-
puts `svn up .`
|
58
|
+
puts `svn #{scm_opts_up} up .`
|
50
59
|
end
|
51
60
|
end
|
52
61
|
else
|
53
|
-
|
62
|
+
co_or_up "up"
|
54
63
|
end
|
55
64
|
end
|
56
65
|
|
57
66
|
def st *args
|
58
67
|
puts "\nstatus for #{path}:"
|
59
68
|
Dir.chdir path do
|
60
|
-
puts `svn status`
|
69
|
+
puts `svn #{scm_opts_st} status`
|
61
70
|
end
|
62
71
|
end
|
63
72
|
|
64
73
|
def self.scm_path? path
|
65
74
|
return true if path =~ /^svn(\+ssh)?:/
|
75
|
+
|
76
|
+
# Look for http(s)://svn.*/*
|
66
77
|
if path =~ /^https?:\/\/([\w+\-_]+)\.(?:[\w+\-_]+\.)*[\w\-_]+(?:\/|$)/
|
67
78
|
return true if $1.downcase == "svn"
|
79
|
+
end
|
68
80
|
|
69
|
-
|
70
|
-
|
71
|
-
|
81
|
+
# Look for http(s)://*/*svn*/
|
82
|
+
if path =~ /^https?:\/\/(?:[\w+\-_]+\.?)+\/(\w+)/
|
83
|
+
return true if $1.downcase.include? "svn"
|
72
84
|
end
|
73
85
|
|
74
86
|
false
|
75
87
|
end
|
76
88
|
|
77
89
|
def self.fill_in_opts opts, main_options, sub_options
|
78
|
-
opts.on("--svn", "--subversion",
|
90
|
+
opts.on("--svn", "--subversion", "same as '--scm svn' Uses subversion to checkout/export the main project",
|
79
91
|
Integer) {sub_options[:scm] = main_options[:scm] = 'svn'}
|
80
92
|
end
|
81
93
|
|
@@ -83,10 +95,13 @@ module Externals
|
|
83
95
|
"svn"
|
84
96
|
end
|
85
97
|
|
98
|
+
install_scm_opts_methods
|
99
|
+
|
86
100
|
def self.detected?
|
87
101
|
File.exists? ".svn"
|
88
102
|
end
|
89
103
|
|
104
|
+
#this is a test helper method
|
90
105
|
def self.add_all
|
91
106
|
status = `svn st`
|
92
107
|
|
@@ -110,7 +125,7 @@ module Externals
|
|
110
125
|
rows << child.strip
|
111
126
|
|
112
127
|
Dir.chdir(parent) do
|
113
|
-
puts `svn propset svn:ignore "#{rows.compact.join("\n")}\n" .`
|
128
|
+
puts `svn #{scm_opts} propset svn:ignore "#{rows.compact.join("\n")}\n" .`
|
114
129
|
end
|
115
130
|
end
|
116
131
|
|
@@ -130,7 +145,7 @@ module Externals
|
|
130
145
|
end
|
131
146
|
|
132
147
|
Dir.chdir(parent) do
|
133
|
-
puts `svn propset svn:ignore "#{rows.compact.join("\n")}\n" .`
|
148
|
+
puts `svn #{scm_opts} propset svn:ignore "#{rows.compact.join("\n")}\n" .`
|
134
149
|
end
|
135
150
|
end
|
136
151
|
|
@@ -145,14 +160,14 @@ module Externals
|
|
145
160
|
def ignore_text(path)
|
146
161
|
ignore_text = ''
|
147
162
|
Dir.chdir File.dirname(path) do
|
148
|
-
ignore_text = `svn propget svn:ignore`
|
163
|
+
ignore_text = `svn #{scm_opts} propget svn:ignore`
|
149
164
|
end
|
150
165
|
ignore_text
|
151
166
|
end
|
152
167
|
|
153
168
|
def current_revision
|
154
169
|
Dir.chdir path do
|
155
|
-
if `svn info` =~ /Revision:\s*(\d+)\s*$/
|
170
|
+
if `svn #{scm_opts} info` =~ /Revision:\s*(\d+)\s*$/
|
156
171
|
$1
|
157
172
|
end
|
158
173
|
end
|
@@ -163,4 +178,4 @@ module Externals
|
|
163
178
|
end
|
164
179
|
|
165
180
|
end
|
166
|
-
end
|
181
|
+
end
|
data/lib/externals/test_case.rb
CHANGED
@@ -100,9 +100,9 @@ module Externals
|
|
100
100
|
Dir.mkdir applications_dir unless File.exists?(applications_dir)
|
101
101
|
Dir.chdir applications_dir do
|
102
102
|
if rails_version =~ /^3([^\d]|$)/
|
103
|
-
puts
|
103
|
+
puts `#{rails_exe} new rails_app`
|
104
104
|
elsif rails_version =~ /^2([^\d]|$)/
|
105
|
-
puts
|
105
|
+
puts `#{rails_exe} rails_app`
|
106
106
|
else
|
107
107
|
raise "can't determine rails version"
|
108
108
|
end
|
@@ -110,7 +110,12 @@ module Externals
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def rails_version
|
113
|
-
/[\d\.]+/.match(
|
113
|
+
/[\d\.]+/.match(`#{rails_exe} --version`)[0]
|
114
|
+
end
|
115
|
+
|
116
|
+
def rails_exe
|
117
|
+
"jruby -S rails"
|
118
|
+
"rails"
|
114
119
|
end
|
115
120
|
|
116
121
|
def windows?
|
data/test/test_checkout_git.rb
CHANGED
@@ -5,7 +5,7 @@ require 'externals/ext'
|
|
5
5
|
module Externals
|
6
6
|
class TestCheckoutGit < TestCase
|
7
7
|
include ExtTestCase
|
8
|
-
|
8
|
+
|
9
9
|
def setup
|
10
10
|
initialize_test_git_repository
|
11
11
|
|
@@ -19,20 +19,20 @@ module Externals
|
|
19
19
|
Dir.chdir File.join(root_dir, 'test') do
|
20
20
|
`rm -rf workdir`
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def test_repository_created
|
26
26
|
assert File.exists?(File.join(repository_dir('git'), '.git'))
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def test_checkout
|
30
30
|
Dir.chdir File.join(root_dir, 'test') do
|
31
31
|
`mkdir workdir`
|
32
|
-
|
32
|
+
|
33
33
|
Dir.chdir 'workdir' do
|
34
34
|
Ext.run "checkout", "--git", repository_dir('git')
|
35
|
-
|
35
|
+
|
36
36
|
assert File.exists?(File.join(repository_dir('git'),'.git'))
|
37
37
|
end
|
38
38
|
end
|
@@ -220,7 +220,13 @@ module Externals
|
|
220
220
|
#freeze it to a revision
|
221
221
|
Ext.run "freeze", subproject, revision
|
222
222
|
Dir.chdir File.join("vendor",'plugins', subproject) do
|
223
|
-
|
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
|
224
230
|
end
|
225
231
|
|
226
232
|
SvnProject.add_all
|
@@ -0,0 +1,136 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
|
2
|
+
require 'externals/test_case'
|
3
|
+
require 'externals/ext'
|
4
|
+
|
5
|
+
module Externals
|
6
|
+
class TestProjects < TestCase
|
7
|
+
include ExtTestCase
|
8
|
+
|
9
|
+
def test_svn_global_opts
|
10
|
+
Dir.chdir File.join(root_dir, 'test') do
|
11
|
+
`rm -rf test_svn_global_opts`
|
12
|
+
`mkdir test_svn_global_opts`
|
13
|
+
|
14
|
+
|
15
|
+
Dir.chdir 'test_svn_global_opts' do
|
16
|
+
open '.externals', 'w' do |f|
|
17
|
+
f.write "[.]
|
18
|
+
scm = git
|
19
|
+
type = rails
|
20
|
+
|
21
|
+
[vendor/plugins/acts_as_list]
|
22
|
+
scm = git
|
23
|
+
repository = git://github.com/rails/acts_as_list.git
|
24
|
+
branch = edge
|
25
|
+
|
26
|
+
[vendor/plugins/foreign_key_migrations]
|
27
|
+
scm = svn
|
28
|
+
repository = svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/foreign_key_migrations
|
29
|
+
"
|
30
|
+
end
|
31
|
+
|
32
|
+
#test no scm_opts set...
|
33
|
+
|
34
|
+
ext = Ext.new
|
35
|
+
|
36
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts, nil
|
37
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_co, nil
|
38
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_up, nil
|
39
|
+
assert_equal ext.main_project.scm_opts, nil
|
40
|
+
assert_equal ext.main_project.scm_opts_co, nil
|
41
|
+
assert_equal ext.main_project.scm_opts_up, nil
|
42
|
+
assert_equal ext.main_project.git_opts, nil
|
43
|
+
assert_equal ext.main_project.svn_opts, nil
|
44
|
+
assert_equal ext.main_project.git_opts_up, nil
|
45
|
+
assert_equal ext.main_project.svn_opts_up, nil
|
46
|
+
|
47
|
+
|
48
|
+
open '.externals', 'w' do |f|
|
49
|
+
f.write "[.]
|
50
|
+
scm = git
|
51
|
+
type = rails
|
52
|
+
|
53
|
+
[vendor/plugins/acts_as_list]
|
54
|
+
scm_opts = --verbose
|
55
|
+
scm = git
|
56
|
+
repository = git://github.com/rails/acts_as_list.git
|
57
|
+
branch = edge
|
58
|
+
|
59
|
+
[vendor/plugins/foreign_key_migrations]
|
60
|
+
scm_opts = --trust-server-cert --non-interactive
|
61
|
+
scm = svn
|
62
|
+
repository = svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/foreign_key_migrations
|
63
|
+
"
|
64
|
+
end
|
65
|
+
|
66
|
+
#test scm_opts set... no _co, _up, etc.
|
67
|
+
|
68
|
+
ext = Ext.new
|
69
|
+
|
70
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts, "--verbose"
|
71
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_co, "--verbose"
|
72
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_up, "--verbose"
|
73
|
+
assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts,
|
74
|
+
"--trust-server-cert --non-interactive"
|
75
|
+
assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts_co,
|
76
|
+
"--trust-server-cert --non-interactive"
|
77
|
+
assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts_up,
|
78
|
+
"--trust-server-cert --non-interactive"
|
79
|
+
assert_equal ext.main_project.scm_opts, nil
|
80
|
+
assert_equal ext.main_project.scm_opts_co, nil
|
81
|
+
assert_equal ext.main_project.scm_opts_up, nil
|
82
|
+
assert_equal ext.main_project.git_opts, nil
|
83
|
+
assert_equal ext.main_project.svn_opts, nil
|
84
|
+
assert_equal ext.main_project.git_opts_up, nil
|
85
|
+
assert_equal ext.main_project.svn_opts_up, nil
|
86
|
+
|
87
|
+
#test global options and specific action options
|
88
|
+
open '.externals', 'w' do |f|
|
89
|
+
f.write "[.]
|
90
|
+
scm = git
|
91
|
+
type = rails
|
92
|
+
svn_opts = --trust-server-cert
|
93
|
+
svn_opts_up = --svn-up
|
94
|
+
git_opts = --verbose
|
95
|
+
scm_opts = --main-project-opts
|
96
|
+
|
97
|
+
[vendor/plugins/acts_as_list]
|
98
|
+
scm_opts_up = --made-up-option
|
99
|
+
scm = git
|
100
|
+
repository = git://github.com/rails/acts_as_list.git
|
101
|
+
branch = edge
|
102
|
+
|
103
|
+
[vendor/plugins/foreign_key_migrations]
|
104
|
+
scm_opts_co = --non-interactive
|
105
|
+
scm = svn
|
106
|
+
repository = svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/foreign_key_migrations
|
107
|
+
"
|
108
|
+
end
|
109
|
+
|
110
|
+
ext = Ext.new
|
111
|
+
|
112
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts, "--verbose"
|
113
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_co, "--verbose"
|
114
|
+
assert_equal ext.subproject_by_name_or_path('acts_as_list').scm_opts_up,
|
115
|
+
"--made-up-option --verbose"
|
116
|
+
assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts,
|
117
|
+
"--trust-server-cert"
|
118
|
+
assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts_co,
|
119
|
+
"--non-interactive --trust-server-cert"
|
120
|
+
assert_equal ext.subproject_by_name_or_path('foreign_key_migrations').scm_opts_up,
|
121
|
+
"--svn-up --trust-server-cert"
|
122
|
+
assert_equal ext.main_project.scm_opts, "--main-project-opts --verbose"
|
123
|
+
assert_equal ext.main_project.scm_opts_co, "--main-project-opts --verbose"
|
124
|
+
assert_equal ext.main_project.scm_opts_up, "--main-project-opts --verbose"
|
125
|
+
assert_equal ext.main_project.git_opts, "--verbose"
|
126
|
+
assert_equal ext.main_project.svn_opts, "--trust-server-cert"
|
127
|
+
assert_equal ext.main_project.git_opts_up, "--verbose"
|
128
|
+
assert_equal ext.main_project.svn_opts_up, "--svn-up --trust-server-cert"
|
129
|
+
|
130
|
+
|
131
|
+
`rm -rf test_svn_global_opts`
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 8
|
9
|
-
version: 0.1.8
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Miles Georgi
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-03-29 00:00:00 -07:00
|
18
14
|
default_executable: ext
|
19
15
|
dependencies: []
|
20
16
|
|
@@ -83,6 +79,7 @@ files:
|
|
83
79
|
- test/test_freeze_to_revision.rb
|
84
80
|
- test/test_checkout_with_subprojects_git.rb
|
85
81
|
- test/test_touch_emptydirs.rb
|
82
|
+
- test/test_projects.rb
|
86
83
|
- bin/ext
|
87
84
|
has_rdoc: true
|
88
85
|
homepage: http://nopugs.com/ext-tutorial
|
@@ -98,21 +95,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
95
|
requirements:
|
99
96
|
- - ">="
|
100
97
|
- !ruby/object:Gem::Version
|
101
|
-
segments:
|
102
|
-
- 0
|
103
98
|
version: "0"
|
104
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
100
|
none: false
|
106
101
|
requirements:
|
107
102
|
- - ">="
|
108
103
|
- !ruby/object:Gem::Version
|
109
|
-
segments:
|
110
|
-
- 0
|
111
104
|
version: "0"
|
112
105
|
requirements: []
|
113
106
|
|
114
107
|
rubyforge_project: ext
|
115
|
-
rubygems_version: 1.
|
108
|
+
rubygems_version: 1.5.0
|
116
109
|
signing_key:
|
117
110
|
specification_version: 3
|
118
111
|
summary: Provides an SCM agnostic way to manage subprojects with a workflow similar to the svn:externals feature of subversion. It's particularly useful for rails projects that have some plugins managed by svn and some managed by git.
|
@@ -128,3 +121,4 @@ test_files:
|
|
128
121
|
- test/test_freeze_to_revision.rb
|
129
122
|
- test/test_checkout_with_subprojects_git.rb
|
130
123
|
- test/test_touch_emptydirs.rb
|
124
|
+
- test/test_projects.rb
|