ext 1.1.2 → 2.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.
- checksums.yaml +7 -0
- data/CHANGELOG +47 -14
- data/LICENSE-MPL-2.0.txt +373 -0
- data/LICENSE.txt +9 -0
- data/README +5 -13
- data/lib/externals/command.rb +6 -5
- data/lib/externals/configuration/configuration.rb +27 -22
- data/lib/externals/ext.rb +164 -186
- data/lib/externals/extensions/file_utils.rb +15 -15
- data/lib/externals/extensions/string.rb +7 -10
- data/lib/externals/project.rb +37 -50
- data/lib/externals/scms/git_project.rb +69 -60
- data/lib/externals/scms/svn_project.rb +57 -29
- data/version.rb +4 -0
- metadata +41 -117
- data/MIT_LICENSE.txt +0 -22
- data/Rakefile +0 -75
- data/lib/externals/extensions/symbol.rb +0 -7
- data/lib/externals/project_types/rails.rb +0 -35
- 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 +0 -32
- data/test/test_checkout_with_subprojects_git.rb +0 -169
- data/test/test_checkout_with_subprojects_svn.rb +0 -384
- data/test/test_file_utils_extensions.rb +0 -29
- data/test/test_freeze_to_revision.rb +0 -176
- data/test/test_git_project_extract_name.rb +0 -20
- data/test/test_help.rb +0 -27
- data/test/test_init_git.rb +0 -40
- data/test/test_out_of_date_git_subproject.rb +0 -83
- data/test/test_projects.rb +0 -148
- data/test/test_rails_detection.rb +0 -23
- data/test/test_string_extensions.rb +0 -51
- data/test/test_svn_branches.rb +0 -353
- data/test/test_touch_emptydirs.rb +0 -59
- data/test/test_version.rb +0 -33
|
@@ -2,34 +2,34 @@ require 'fileutils'
|
|
|
2
2
|
|
|
3
3
|
FileUtils.class_eval do
|
|
4
4
|
# simulates cp -a
|
|
5
|
-
def cp_a source, dest, options
|
|
6
|
-
cp_r source, dest, options
|
|
5
|
+
def cp_a source, dest, **options
|
|
6
|
+
cp_r source, dest, **options, :preserve => true
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
# calls rm_rf if the file exists
|
|
10
|
-
def rm_rf_ie file, options
|
|
11
|
-
rm_rf
|
|
10
|
+
def rm_rf_ie file, **options
|
|
11
|
+
rm_rf(file, **options) if File.exist?(file)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
# calls rmdir if the file exists and is empty
|
|
15
15
|
def rmdir_if_empty_ie path
|
|
16
|
-
rmdir path if File.
|
|
16
|
+
rmdir path if File.exist?(path) && dir_empty?(path)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# calls rmdir if the file exists
|
|
20
20
|
def rmdir_ie path
|
|
21
|
-
rmdir path if File.
|
|
21
|
+
rmdir path if File.exist?(path)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
alias_method :rm_rf_old, :rm_rf
|
|
25
25
|
#going to try to give a delay after calling rm if necessary...
|
|
26
|
-
def rm_rf *args
|
|
26
|
+
def rm_rf(filename, *args, **opts)
|
|
27
27
|
tries = 0
|
|
28
28
|
|
|
29
29
|
rm = proc do
|
|
30
|
-
rm_rf_old *args
|
|
30
|
+
rm_rf_old(filename, *args, **opts)
|
|
31
31
|
|
|
32
|
-
while File.
|
|
32
|
+
while File.exist?(filename) && tries < 10
|
|
33
33
|
# :nocov:
|
|
34
34
|
sleep 1
|
|
35
35
|
tries += 1
|
|
@@ -40,12 +40,12 @@ FileUtils.class_eval do
|
|
|
40
40
|
rm.call
|
|
41
41
|
if tries >= 10
|
|
42
42
|
# :nocov:
|
|
43
|
-
puts "WARNING: deleted #{
|
|
43
|
+
puts "WARNING: deleted #{filename} didn't work, trying again"
|
|
44
44
|
tries = 0
|
|
45
45
|
rm.call
|
|
46
46
|
|
|
47
47
|
if tries >= 10
|
|
48
|
-
raise "Could not delete #{
|
|
48
|
+
raise "Could not delete #{filename}"
|
|
49
49
|
end
|
|
50
50
|
# :nocov:
|
|
51
51
|
end
|
|
@@ -53,7 +53,7 @@ FileUtils.class_eval do
|
|
|
53
53
|
|
|
54
54
|
def dir_empty? path
|
|
55
55
|
File.directory?(path) &&
|
|
56
|
-
File.
|
|
57
|
-
!Dir.entries(path).detect{|entry| !["..","."].include?(entry)}
|
|
56
|
+
File.exist?(path) &&
|
|
57
|
+
!Dir.entries(path).detect{|entry| !["..", "."].include?(entry)}
|
|
58
58
|
end
|
|
59
|
-
end
|
|
59
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
String.class_eval do
|
|
2
2
|
def cap_first
|
|
3
|
-
"#{self[0].chr.upcase}#{self[1..
|
|
3
|
+
"#{self[0].chr.upcase}#{self[1..]}"
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
def classify
|
|
@@ -8,24 +8,22 @@ String.class_eval do
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
#avoid collision
|
|
11
|
-
raise if
|
|
11
|
+
raise if method_defined?("lines_by_width")
|
|
12
|
+
|
|
12
13
|
def lines_by_width(width = 32)
|
|
13
14
|
width ||= 32
|
|
14
15
|
lines = []
|
|
15
16
|
string = gsub(/\s+/, ' ')
|
|
16
|
-
|
|
17
|
+
until string.empty?
|
|
17
18
|
if string.size <= width
|
|
18
19
|
lines << string
|
|
19
20
|
string = ""
|
|
20
21
|
else
|
|
21
22
|
index = string[0, width + 1].rindex(/\s/)
|
|
22
|
-
|
|
23
|
-
# let's find the first space we can.
|
|
24
|
-
index = string.index(/\s/)
|
|
25
|
-
end
|
|
23
|
+
index ||= string.index(/\s/)
|
|
26
24
|
if index
|
|
27
25
|
lines << string[0, index]
|
|
28
|
-
string = string[(index + 1)
|
|
26
|
+
string = string[(index + 1)..]
|
|
29
27
|
else
|
|
30
28
|
lines << string
|
|
31
29
|
string = ""
|
|
@@ -35,5 +33,4 @@ String.class_eval do
|
|
|
35
33
|
|
|
36
34
|
lines
|
|
37
35
|
end
|
|
38
|
-
|
|
39
|
-
end
|
|
36
|
+
end
|
data/lib/externals/project.rb
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
require 'externals/extensions/symbol'
|
|
2
1
|
require 'fileutils'
|
|
3
2
|
|
|
4
3
|
module Externals
|
|
5
|
-
OPTS_SUFFIXES = ["co", "up", "st", "ex"]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
OPTS_SUFFIXES = ["co", "up", "st", "ex"].freeze unless const_defined?('OPTS_SUFFIXES')
|
|
5
|
+
unless const_defined?('VALID_ATTRIB')
|
|
6
|
+
VALID_ATTRIB = [
|
|
7
|
+
:name, :path, :repository, :branch, :scm, :revision
|
|
8
|
+
].map(&:to_s)
|
|
9
|
+
end
|
|
10
10
|
|
|
11
11
|
class Project
|
|
12
12
|
attr_accessor :parent
|
|
13
|
+
|
|
13
14
|
include FileUtils
|
|
14
15
|
extend FileUtils
|
|
15
16
|
|
|
16
17
|
def self.attr_attr_accessor *names
|
|
17
18
|
names = [names].flatten
|
|
18
19
|
names.each do |name|
|
|
19
|
-
define_method name do
|
|
20
|
-
attributes[name.to_sym]
|
|
21
|
-
end
|
|
22
20
|
define_method "#{name}=" do |value|
|
|
23
21
|
attributes[name.to_sym] = value
|
|
24
22
|
end
|
|
23
|
+
next if name == "name" || name == "scm"
|
|
24
|
+
|
|
25
|
+
define_method name do
|
|
26
|
+
attributes[name.to_sym]
|
|
27
|
+
end
|
|
25
28
|
end
|
|
26
29
|
end
|
|
27
30
|
|
|
28
|
-
|
|
29
31
|
attr_attr_accessor Externals::VALID_ATTRIB
|
|
30
32
|
def attributes
|
|
31
33
|
@attributes ||= {}
|
|
32
34
|
end
|
|
35
|
+
|
|
33
36
|
def name
|
|
34
37
|
attributes[:name] || extract_name(repository)
|
|
35
38
|
end
|
|
39
|
+
|
|
36
40
|
def main_project?
|
|
37
41
|
path == '.'
|
|
38
42
|
end
|
|
@@ -47,25 +51,18 @@ module Externals
|
|
|
47
51
|
self.class.scm
|
|
48
52
|
end
|
|
49
53
|
|
|
50
|
-
def
|
|
51
|
-
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def default_branch
|
|
55
|
-
self.class.default_branch
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def switch branch_name, options = {}
|
|
54
|
+
def switch _branch_name, _options = {}
|
|
55
|
+
# :nocov:
|
|
59
56
|
raise "subclass responsibility"
|
|
57
|
+
# :nocov:
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
def initialize hash
|
|
63
61
|
raise "Abstract class" if self.class == Project
|
|
64
62
|
raise "expected hash" unless hash.is_a? Hash
|
|
65
63
|
|
|
66
|
-
hash = hash.keys.
|
|
67
|
-
|
|
68
|
-
new_hash
|
|
64
|
+
hash = hash.keys.to_h do |key|
|
|
65
|
+
[key.to_s, hash[key]]
|
|
69
66
|
end
|
|
70
67
|
|
|
71
68
|
invalid_attrib = hash.keys - Externals::VALID_ATTRIB
|
|
@@ -75,25 +72,26 @@ module Externals
|
|
|
75
72
|
attribute =~ /^\w+_opts(_(#{OPTS_SUFFIXES.join("|")}))?/
|
|
76
73
|
end
|
|
77
74
|
if !invalid_attrib.empty?
|
|
75
|
+
# :nocov:
|
|
78
76
|
raise "invalid attribute(s): #{invalid_attrib.join(', ')}"
|
|
77
|
+
# :nocov:
|
|
79
78
|
end
|
|
80
79
|
end
|
|
81
80
|
|
|
82
81
|
path = hash.delete('path')
|
|
83
82
|
|
|
84
|
-
hash.
|
|
85
|
-
send("#{key}=",
|
|
83
|
+
hash.each_pair do |key, value|
|
|
84
|
+
send("#{key}=", value)
|
|
86
85
|
end
|
|
87
86
|
|
|
88
|
-
if path && !path.is_a?(String)
|
|
89
|
-
path = path.default_path(name)
|
|
90
|
-
end
|
|
91
87
|
self.path = path
|
|
92
88
|
end
|
|
93
89
|
|
|
94
90
|
[:co, :ex].each do |method_name|
|
|
95
|
-
define_method method_name do
|
|
91
|
+
define_method method_name do
|
|
92
|
+
# :nocov:
|
|
96
93
|
raise "subclass responsibility"
|
|
94
|
+
# :nocov:
|
|
97
95
|
end
|
|
98
96
|
end
|
|
99
97
|
|
|
@@ -112,7 +110,7 @@ module Externals
|
|
|
112
110
|
end
|
|
113
111
|
|
|
114
112
|
def extract_name repository
|
|
115
|
-
if repository =~ /\/([\
|
|
113
|
+
if repository =~ /\/([\w-]+)(?:\.git)?$/
|
|
116
114
|
$1
|
|
117
115
|
end
|
|
118
116
|
end
|
|
@@ -128,11 +126,11 @@ module Externals
|
|
|
128
126
|
end
|
|
129
127
|
|
|
130
128
|
exists.each do |proj|
|
|
131
|
-
assert.call File.
|
|
129
|
+
assert.call File.exist?(File.join('vendor', 'plugins', proj, 'lib'))
|
|
132
130
|
end
|
|
133
131
|
|
|
134
132
|
doesnt.each do |proj|
|
|
135
|
-
assert.call !File.
|
|
133
|
+
assert.call !File.exist?(File.join('vendor', 'plugins', proj, 'lib'))
|
|
136
134
|
end
|
|
137
135
|
end
|
|
138
136
|
|
|
@@ -153,7 +151,7 @@ module Externals
|
|
|
153
151
|
|
|
154
152
|
# create the suffixed versions
|
|
155
153
|
OPTS_SUFFIXES.map do |suffix|
|
|
156
|
-
|
|
154
|
+
"scm_opts_#{suffix}"
|
|
157
155
|
end.each do |name|
|
|
158
156
|
define_method name do
|
|
159
157
|
values = [
|
|
@@ -172,8 +170,9 @@ module Externals
|
|
|
172
170
|
end
|
|
173
171
|
end
|
|
174
172
|
|
|
175
|
-
|
|
176
173
|
def self.inherited child
|
|
174
|
+
super
|
|
175
|
+
|
|
177
176
|
child.class_eval do
|
|
178
177
|
def self.scm
|
|
179
178
|
@scm ||= /^([^:]*::)*([^:]+)Project$/.match(name)[2].downcase
|
|
@@ -189,24 +188,21 @@ module Externals
|
|
|
189
188
|
#of the suffixed versions (<scm_name>_opts_co) as well as the project
|
|
190
189
|
#specific ones. (scm_opts, scm_opts_co, etc)
|
|
191
190
|
scm_name = scm
|
|
192
|
-
Project.__send__(:define_method, "#{scm_name}_opts_raw") do
|
|
193
|
-
attributes[name.to_sym]
|
|
194
|
-
end
|
|
195
191
|
#global settings are fetched from the parent project.
|
|
196
192
|
Project.__send__(:define_method, "#{scm_name}_opts") do
|
|
197
193
|
if parent
|
|
198
194
|
parent.__send__("#{scm_name}_opts")
|
|
199
195
|
else
|
|
200
|
-
attributes["#{scm_name}_opts"
|
|
196
|
+
attributes[:"#{scm_name}_opts"]
|
|
201
197
|
end
|
|
202
198
|
end
|
|
203
199
|
Project.__send__(:define_method, "#{scm_name}_opts=") do |value|
|
|
204
|
-
attributes["#{scm_name}_opts"
|
|
200
|
+
attributes[:"#{scm_name}_opts"] = value
|
|
205
201
|
end
|
|
206
202
|
|
|
207
203
|
#now we create the suffixed version of the global settings.
|
|
208
204
|
OPTS_SUFFIXES.map do |suffix|
|
|
209
|
-
|
|
205
|
+
"#{scm_name}_opts_#{suffix}"
|
|
210
206
|
end.each do |name|
|
|
211
207
|
#defer to the parent project for these global settings
|
|
212
208
|
Project.__send__(:define_method, name) do
|
|
@@ -215,7 +211,7 @@ module Externals
|
|
|
215
211
|
else
|
|
216
212
|
values = [
|
|
217
213
|
attributes[name.to_sym],
|
|
218
|
-
|
|
214
|
+
send("#{scm_name}_opts")
|
|
219
215
|
].compact
|
|
220
216
|
|
|
221
217
|
if !values.empty?
|
|
@@ -231,15 +227,6 @@ module Externals
|
|
|
231
227
|
end
|
|
232
228
|
|
|
233
229
|
protected
|
|
234
|
-
def trim_quotes value
|
|
235
|
-
if value
|
|
236
|
-
if [value[0].chr, value[-1].chr] == ['"', '"']
|
|
237
|
-
value[1..-2]
|
|
238
|
-
else
|
|
239
|
-
value
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
230
|
|
|
244
231
|
#helper method for converting "co" into "scm_opts_co" and "" into "scm_opts"
|
|
245
232
|
def resolve_opts command = ""
|
|
@@ -247,4 +234,4 @@ module Externals
|
|
|
247
234
|
send("scm_opts#{command}")
|
|
248
235
|
end
|
|
249
236
|
end
|
|
250
|
-
end
|
|
237
|
+
end
|
|
@@ -2,11 +2,8 @@ require File.join(File.dirname(__FILE__), '..', 'project')
|
|
|
2
2
|
|
|
3
3
|
module Externals
|
|
4
4
|
class GitProject < Project
|
|
5
|
-
def default_branch
|
|
6
|
-
'master'
|
|
7
|
-
end
|
|
8
|
-
|
|
9
5
|
private
|
|
6
|
+
|
|
10
7
|
def do_clone command, extra_opts = ""
|
|
11
8
|
opts = resolve_opts(command)
|
|
12
9
|
|
|
@@ -22,25 +19,30 @@ module Externals
|
|
|
22
19
|
puts(gitclonecmd = "git #{opts} clone #{extra_opts} \"#{repository}\" #{dest}")
|
|
23
20
|
puts `#{gitclonecmd}`
|
|
24
21
|
unless $? == 0
|
|
22
|
+
# :nocov:
|
|
25
23
|
raise "git clone of #{repository} failed."
|
|
24
|
+
# :nocov:
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
|
|
29
28
|
public
|
|
30
|
-
|
|
29
|
+
|
|
30
|
+
def co *_args
|
|
31
31
|
do_up "co"
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
private
|
|
35
|
+
|
|
35
36
|
# make sure you have already entered Dir.chdir(path) in your calling code!
|
|
36
37
|
def branch_exists branch_name
|
|
37
38
|
opts = resolve_opts
|
|
38
|
-
`git #{opts} branch -a` =~
|
|
39
|
+
`git #{opts} branch -a` =~ /^[\s*]*#{branch_name}\s*$/
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
# make sure you have already entered Dir.chdir(path) in your calling code!
|
|
42
43
|
|
|
43
44
|
public
|
|
45
|
+
|
|
44
46
|
# this method fetches/pulls/changes branches/changes revisions/changes the oil in your geo metro/brings world peace
|
|
45
47
|
def change_to_branch_revision command = ""
|
|
46
48
|
opts = resolve_opts(command)
|
|
@@ -48,16 +50,15 @@ module Externals
|
|
|
48
50
|
pulled = false
|
|
49
51
|
|
|
50
52
|
project_path = if path == "."
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
name || "."
|
|
54
|
+
else
|
|
55
|
+
path
|
|
56
|
+
end
|
|
55
57
|
|
|
56
58
|
Dir.chdir project_path do
|
|
57
59
|
do_fetch command
|
|
58
60
|
end
|
|
59
61
|
|
|
60
|
-
|
|
61
62
|
if branch
|
|
62
63
|
cb = current_branch
|
|
63
64
|
|
|
@@ -78,7 +79,9 @@ module Externals
|
|
|
78
79
|
puts `git #{opts} checkout --track -b #{branch} origin/#{branch}`
|
|
79
80
|
end
|
|
80
81
|
unless $? == 0
|
|
82
|
+
# :nocov:
|
|
81
83
|
raise "Could not checkout origin/#{branch}"
|
|
84
|
+
# :nocov:
|
|
82
85
|
end
|
|
83
86
|
end
|
|
84
87
|
end
|
|
@@ -87,6 +90,7 @@ module Externals
|
|
|
87
90
|
Dir.chdir project_path do
|
|
88
91
|
`git #{opts} pull`
|
|
89
92
|
raise unless $? == 0
|
|
93
|
+
|
|
90
94
|
pulled = true
|
|
91
95
|
end
|
|
92
96
|
end
|
|
@@ -95,7 +99,9 @@ module Externals
|
|
|
95
99
|
Dir.chdir project_path do
|
|
96
100
|
puts `git #{opts} checkout #{revision}`
|
|
97
101
|
unless $? == 0
|
|
102
|
+
# :nocov:
|
|
98
103
|
raise "Could not checkout #{revision}"
|
|
104
|
+
# :nocov:
|
|
99
105
|
end
|
|
100
106
|
end
|
|
101
107
|
else
|
|
@@ -108,29 +114,25 @@ module Externals
|
|
|
108
114
|
end
|
|
109
115
|
end
|
|
110
116
|
|
|
111
|
-
def switch branch_name,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
# and if not, fetch it.
|
|
121
|
-
if !branch_exists("origin/#{branch_name}")
|
|
122
|
-
puts `git #{scm_opts} fetch`
|
|
123
|
-
end
|
|
117
|
+
def switch branch_name, _options = {}
|
|
118
|
+
# This allows the main project to be checked out to a directory
|
|
119
|
+
# that doesn't match it's name.
|
|
120
|
+
Dir.chdir path do
|
|
121
|
+
# let's see if the branch exists in the remote repository
|
|
122
|
+
# and if not, fetch it.
|
|
123
|
+
if !branch_exists("origin/#{branch_name}")
|
|
124
|
+
puts `git #{scm_opts} fetch`
|
|
125
|
+
end
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
if branch_exists(branch_name)
|
|
128
|
+
puts `git #{scm_opts} checkout #{branch_name}`
|
|
129
|
+
else
|
|
130
|
+
puts `git #{resolve_opts("co")} checkout --track -b #{branch_name}`
|
|
131
|
+
end
|
|
132
|
+
unless $? == 0
|
|
133
|
+
# :nocov:
|
|
134
|
+
raise "Could not checkout origin/#{branch_name}"
|
|
135
|
+
# :nocov:
|
|
134
136
|
end
|
|
135
137
|
end
|
|
136
138
|
end
|
|
@@ -139,7 +141,7 @@ module Externals
|
|
|
139
141
|
if revision
|
|
140
142
|
# No clean reliable way to clone something that's not a branch or tag.
|
|
141
143
|
# just call up instead.
|
|
142
|
-
up
|
|
144
|
+
up(*args)
|
|
143
145
|
else
|
|
144
146
|
clone_opts = "--depth 1"
|
|
145
147
|
if branch
|
|
@@ -149,11 +151,12 @@ module Externals
|
|
|
149
151
|
end
|
|
150
152
|
end
|
|
151
153
|
|
|
152
|
-
def up *
|
|
154
|
+
def up *_args
|
|
153
155
|
do_up "up"
|
|
154
156
|
end
|
|
155
157
|
|
|
156
158
|
private
|
|
159
|
+
|
|
157
160
|
def do_fetch command
|
|
158
161
|
opts = resolve_opts(command)
|
|
159
162
|
`git #{opts} fetch`
|
|
@@ -161,29 +164,28 @@ module Externals
|
|
|
161
164
|
end
|
|
162
165
|
|
|
163
166
|
def do_up command
|
|
164
|
-
opts = resolve_opts(command)
|
|
165
|
-
|
|
166
167
|
project_path = if path == "."
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
168
|
+
name || "." # if no name is specified then we are expected to already be in the right path.
|
|
169
|
+
# this is a little confusing and should be cleaned up.
|
|
170
|
+
# When we are doing a checkout, the name is set manually in Ext.checkout.
|
|
171
|
+
# we are then in the parent directory.
|
|
172
|
+
# When we are doing an update, the main project has no name.
|
|
173
|
+
# we are then in the correct directory.
|
|
174
|
+
else
|
|
175
|
+
path
|
|
176
|
+
end
|
|
176
177
|
|
|
177
178
|
puts "Updating #{path}..."
|
|
178
179
|
|
|
179
|
-
if !File.
|
|
180
|
+
if !File.exist?(project_path)
|
|
180
181
|
do_clone command
|
|
181
182
|
end
|
|
182
183
|
change_to_branch_revision command
|
|
183
184
|
end
|
|
184
185
|
|
|
185
186
|
public
|
|
186
|
-
|
|
187
|
+
|
|
188
|
+
def st *_args
|
|
187
189
|
puts "\nstatus for #{path}:"
|
|
188
190
|
Dir.chdir path do
|
|
189
191
|
puts `git #{scm_opts_st} status`
|
|
@@ -196,29 +198,33 @@ module Externals
|
|
|
196
198
|
|
|
197
199
|
def self.fill_in_opts opts, main_options, sub_options, options
|
|
198
200
|
opts.on("--git", "-g",
|
|
199
|
-
|
|
200
|
-
|
|
201
|
+
Integer,
|
|
202
|
+
*"same as '--scm git' Uses git to
|
|
201
203
|
checkout/export the main project".lines_by_width(options[:summary_width])
|
|
202
204
|
) {sub_options[:scm] = main_options[:scm] = 'git'}
|
|
203
205
|
end
|
|
204
206
|
|
|
205
207
|
def self.detected?
|
|
206
|
-
File.
|
|
208
|
+
File.exist?(".git")
|
|
207
209
|
end
|
|
208
210
|
|
|
209
211
|
#this is a test helper method
|
|
212
|
+
# TODO: can we move it to the test suite, then?
|
|
210
213
|
def self.add_all
|
|
214
|
+
# :nocov:
|
|
211
215
|
puts `git add .`
|
|
212
216
|
raise unless $? == 0
|
|
217
|
+
# :nocov:
|
|
213
218
|
end
|
|
214
219
|
|
|
215
220
|
def ignore_contains? path
|
|
216
221
|
text = ignore_text(path)
|
|
217
|
-
text.split(
|
|
222
|
+
text.split("\n").detect {|r| r.strip == path.strip}
|
|
218
223
|
end
|
|
219
224
|
|
|
220
|
-
def ignore_text(
|
|
221
|
-
return '' unless File.
|
|
225
|
+
def ignore_text(_path = nil)
|
|
226
|
+
return '' unless File.exist?('.gitignore')
|
|
227
|
+
|
|
222
228
|
retval = ''
|
|
223
229
|
open('.gitignore') do |f|
|
|
224
230
|
retval = f.read
|
|
@@ -229,7 +235,7 @@ module Externals
|
|
|
229
235
|
def ignore_rows(path)
|
|
230
236
|
rows = ignore_text(path) || ''
|
|
231
237
|
|
|
232
|
-
rows = rows.split(
|
|
238
|
+
rows = rows.split("\n")
|
|
233
239
|
|
|
234
240
|
rows.delete_if {|row| row =~ /^\s*$/}
|
|
235
241
|
|
|
@@ -250,14 +256,18 @@ module Externals
|
|
|
250
256
|
|
|
251
257
|
def drop_from_ignore path
|
|
252
258
|
ir = ignore_rows(path)
|
|
253
|
-
rows = ir.
|
|
259
|
+
rows = ir.reject {|row| row.strip == path.strip}
|
|
254
260
|
|
|
255
261
|
if rows.size == ir.size
|
|
262
|
+
# :nocov:
|
|
256
263
|
raise "row not found matching #{path} in .gitignore"
|
|
264
|
+
# :nocov:
|
|
257
265
|
end
|
|
258
266
|
|
|
259
267
|
if ir.size - rows.size != 1
|
|
268
|
+
# :nocov:
|
|
260
269
|
raise "More than one row found matching #{path} in .gitignore"
|
|
270
|
+
# :nocov:
|
|
261
271
|
end
|
|
262
272
|
|
|
263
273
|
open('.gitignore', 'w') do |f|
|
|
@@ -281,11 +291,10 @@ module Externals
|
|
|
281
291
|
end
|
|
282
292
|
end
|
|
283
293
|
|
|
284
|
-
def extract_name
|
|
285
|
-
if
|
|
294
|
+
def extract_name string
|
|
295
|
+
if string =~ /([^\/:]+?)(?:\.git|\.bundle)?$/
|
|
286
296
|
$1
|
|
287
297
|
end
|
|
288
298
|
end
|
|
289
|
-
|
|
290
299
|
end
|
|
291
|
-
end
|
|
300
|
+
end
|