nucleon 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/nucleon/project/git.rb +167 -149
- data/nucleon.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 966899ec9ca819e5cbfc37f589762d08ee4d37d0
|
4
|
+
data.tar.gz: c39dc67b0a2ed70f0de66eac0b1caaccd452353c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e20ea49274b90ba8f883ba9e8481ca9ba080678e3bf996b15a5abefb31d5d59b0b194e0f3c5db6b07be30ccba024d75d80f267ead918c049469c48b60c1c3fb
|
7
|
+
data.tar.gz: 6b9ce73ba51a95c903969b80334c05a520746a23d6e4e06e59b2aa81f49d0c93ce607c48db87cfe4054b09093c1c927a174da92f833b3fed81668fa911933467
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
data/lib/nucleon/project/git.rb
CHANGED
@@ -2,28 +2,30 @@
|
|
2
2
|
module Nucleon
|
3
3
|
module Project
|
4
4
|
class Git < Nucleon.plugin_class(:nucleon, :project)
|
5
|
-
|
5
|
+
|
6
6
|
#-----------------------------------------------------------------------------
|
7
7
|
# Project plugin interface
|
8
|
-
|
8
|
+
|
9
9
|
def normalize(reload)
|
10
10
|
unless reload
|
11
11
|
@cli = Util::Liquid.new do |method, args, &code|
|
12
12
|
options = {}
|
13
13
|
options = args.shift if args.length > 0
|
14
|
-
git_exec(method, options, args, &code)
|
14
|
+
git_exec(method, options, args, &code)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
@ignore_cache = {}
|
19
|
+
super
|
18
20
|
end
|
19
|
-
|
21
|
+
|
20
22
|
#-----------------------------------------------------------------------------
|
21
23
|
# Git interface (local)
|
22
|
-
|
24
|
+
|
23
25
|
def ensure_git(reset = false)
|
24
26
|
if reset || @repo.nil?
|
25
27
|
if directory.empty?
|
26
|
-
logger.warn("Can not manage Git project at #{directory} as it does not exist")
|
28
|
+
logger.warn("Can not manage Git project at #{directory} as it does not exist")
|
27
29
|
else
|
28
30
|
logger.debug("Ensuring Git instance to manage #{directory}")
|
29
31
|
@repo = Util::Git.load(directory, {
|
@@ -34,18 +36,18 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
34
36
|
return myself
|
35
37
|
end
|
36
38
|
protected :ensure_git
|
37
|
-
|
39
|
+
|
38
40
|
#-----------------------------------------------------------------------------
|
39
41
|
# Checks
|
40
|
-
|
42
|
+
|
41
43
|
def can_persist?
|
42
44
|
ensure_git
|
43
45
|
return true unless @repo.nil?
|
44
46
|
return false
|
45
47
|
end
|
46
|
-
|
48
|
+
|
47
49
|
#---
|
48
|
-
|
50
|
+
|
49
51
|
def top?(path)
|
50
52
|
git_dir = File.join(path, '.git')
|
51
53
|
if File.exist?(git_dir)
|
@@ -55,25 +57,25 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
55
57
|
end
|
56
58
|
return false
|
57
59
|
end
|
58
|
-
|
60
|
+
|
59
61
|
#---
|
60
|
-
|
62
|
+
|
61
63
|
def subproject?(path)
|
62
64
|
git_dir = File.join(path, '.git')
|
63
65
|
if File.exist?(git_dir)
|
64
66
|
unless File.directory?(git_dir)
|
65
|
-
git_dir = Util::Disk.read(git_dir)
|
67
|
+
git_dir = Util::Disk.read(git_dir)
|
66
68
|
unless git_dir.nil?
|
67
69
|
git_dir = git_dir.gsub(/^gitdir\:\s*/, '').strip
|
68
70
|
return true if File.directory?(git_dir)
|
69
|
-
end
|
71
|
+
end
|
70
72
|
end
|
71
73
|
end
|
72
74
|
return false
|
73
75
|
end
|
74
|
-
|
76
|
+
|
75
77
|
#---
|
76
|
-
|
78
|
+
|
77
79
|
def project_directory?(path, require_top_level = false)
|
78
80
|
path = File.expand_path(path)
|
79
81
|
git_dir = File.join(path, '.git')
|
@@ -86,53 +88,53 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
86
88
|
unless git_dir.nil?
|
87
89
|
git_dir = git_dir.gsub(/^gitdir\:\s*/, '').strip
|
88
90
|
return true if File.directory?(git_dir)
|
89
|
-
end
|
91
|
+
end
|
90
92
|
end
|
91
93
|
elsif File.exist?(path) && (path =~ /\.git$/ && File.exist?(File.join(path, 'HEAD')))
|
92
94
|
return true
|
93
95
|
end
|
94
96
|
return false
|
95
97
|
end
|
96
|
-
|
98
|
+
|
97
99
|
#---
|
98
|
-
|
100
|
+
|
99
101
|
def new?(reset = false)
|
100
102
|
if get(:new, nil).nil? || reset
|
101
103
|
result = cli.rev_parse({ :all => true })
|
102
|
-
|
104
|
+
|
103
105
|
if result && result.status == code.success
|
104
106
|
set(:new, result.output.empty?)
|
105
|
-
end
|
107
|
+
end
|
106
108
|
end
|
107
109
|
get(:new, false)
|
108
110
|
end
|
109
|
-
|
111
|
+
|
110
112
|
#-----------------------------------------------------------------------------
|
111
113
|
# Property accessors / modifiers
|
112
|
-
|
114
|
+
|
113
115
|
def repo
|
114
116
|
return @repo if can_persist?
|
115
117
|
return nil
|
116
118
|
end
|
117
119
|
protected :repo
|
118
|
-
|
120
|
+
|
119
121
|
#---
|
120
|
-
|
122
|
+
|
121
123
|
def cli
|
122
124
|
@cli
|
123
125
|
end
|
124
|
-
|
126
|
+
|
125
127
|
#---
|
126
|
-
|
128
|
+
|
127
129
|
def set_location(directory)
|
128
130
|
super do
|
129
131
|
ensure_git(true)
|
130
132
|
end
|
131
133
|
return myself
|
132
134
|
end
|
133
|
-
|
135
|
+
|
134
136
|
#---
|
135
|
-
|
137
|
+
|
136
138
|
def config(name, options = {})
|
137
139
|
return super do |config|
|
138
140
|
result = cli.config(config.export, name)
|
@@ -140,42 +142,42 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
140
142
|
nil
|
141
143
|
end
|
142
144
|
end
|
143
|
-
|
145
|
+
|
144
146
|
#---
|
145
|
-
|
147
|
+
|
146
148
|
def set_config(name, value, options = {})
|
147
149
|
return super do |config, processed_value|
|
148
150
|
result = cli.config(config.export, name, processed_value)
|
149
151
|
result.status == code.success
|
150
152
|
end
|
151
153
|
end
|
152
|
-
|
154
|
+
|
153
155
|
#---
|
154
|
-
|
156
|
+
|
155
157
|
def delete_config(name, options = {})
|
156
158
|
return super do |config|
|
157
159
|
result = cli.config(config.import({ :remove_section => true }).export, name)
|
158
160
|
result.status == code.success
|
159
161
|
end
|
160
162
|
end
|
161
|
-
|
163
|
+
|
162
164
|
#---
|
163
|
-
|
165
|
+
|
164
166
|
def subproject_config(options = {})
|
165
167
|
return super do |config|
|
166
168
|
result = {}
|
167
|
-
|
169
|
+
|
168
170
|
if new?
|
169
|
-
logger.debug("Project has no sub project configuration yet (has not been committed to)")
|
171
|
+
logger.debug("Project has no sub project configuration yet (has not been committed to)")
|
170
172
|
else
|
171
173
|
gitmodules_file = File.join(directory, '.gitmodules')
|
172
|
-
|
174
|
+
|
173
175
|
gitmodules_data = ''
|
174
176
|
gitmodules_data = Util::Disk.read(gitmodules_file) if File.exists?(gitmodules_file)
|
175
|
-
|
177
|
+
|
176
178
|
unless gitmodules_data.empty?
|
177
179
|
logger.debug("Houston, we have some gitmodules!")
|
178
|
-
|
180
|
+
|
179
181
|
lines = gitmodules_data.gsub(/\r\n?/, "\n" ).split("\n")
|
180
182
|
current = nil
|
181
183
|
|
@@ -183,9 +185,9 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
183
185
|
if line =~ /^\[submodule "(.+)"\]$/
|
184
186
|
current = $1
|
185
187
|
result[current] = {}
|
186
|
-
|
188
|
+
|
187
189
|
logger.debug("Reading: #{current}")
|
188
|
-
|
190
|
+
|
189
191
|
elsif line =~ /^\s*(\w+)\s*=\s*(.+)\s*$/
|
190
192
|
result[current][$1] = $2
|
191
193
|
end
|
@@ -195,35 +197,35 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
195
197
|
result
|
196
198
|
end
|
197
199
|
end
|
198
|
-
|
200
|
+
|
199
201
|
#-----------------------------------------------------------------------------
|
200
202
|
# Operations
|
201
|
-
|
203
|
+
|
202
204
|
def init_cache
|
203
205
|
super
|
204
|
-
ignore(cache.directory_name)
|
206
|
+
ignore(cache.directory_name)
|
205
207
|
end
|
206
|
-
|
208
|
+
|
207
209
|
#-----------------------------------------------------------------------------
|
208
210
|
# Basic Git operations
|
209
|
-
|
211
|
+
|
210
212
|
def ignore(files)
|
211
213
|
super do
|
212
214
|
ensure_in_gitignore(files)
|
213
|
-
end
|
215
|
+
end
|
214
216
|
end
|
215
|
-
|
217
|
+
|
216
218
|
#---
|
217
|
-
|
219
|
+
|
218
220
|
def load_revision
|
219
221
|
return super do
|
220
222
|
if new?
|
221
223
|
logger.debug("Project has no current revision yet (has not been committed to)")
|
222
|
-
nil
|
224
|
+
nil
|
223
225
|
else
|
224
226
|
current_revision = nil
|
225
227
|
result = cli.rev_parse({ :abbrev_ref => true }, 'HEAD')
|
226
|
-
|
228
|
+
|
227
229
|
if result && result.status == code.success
|
228
230
|
current_revision = result.output
|
229
231
|
end
|
@@ -232,13 +234,13 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
232
234
|
end
|
233
235
|
end
|
234
236
|
end
|
235
|
-
|
237
|
+
|
236
238
|
#---
|
237
|
-
|
239
|
+
|
238
240
|
def checkout(revision)
|
239
241
|
return super do |success|
|
240
242
|
if new?
|
241
|
-
logger.debug("Project can not be checked out (has not been committed to)")
|
243
|
+
logger.debug("Project can not be checked out (has not been committed to)")
|
242
244
|
else
|
243
245
|
unless repo.bare?
|
244
246
|
result = cli.checkout({}, revision)
|
@@ -247,131 +249,131 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
247
249
|
result && result.status == code.success
|
248
250
|
end
|
249
251
|
end
|
250
|
-
|
252
|
+
|
251
253
|
#---
|
252
|
-
|
254
|
+
|
253
255
|
def commit(files = '.', options = {})
|
254
256
|
return super do |config, time, user, message|
|
255
257
|
cli.reset({}, 'HEAD') unless new? # Clear the index so we get a clean commit
|
256
|
-
|
258
|
+
|
257
259
|
files = array(files)
|
258
|
-
|
260
|
+
|
259
261
|
logger.debug("Adding files to Git index")
|
260
|
-
|
262
|
+
|
261
263
|
cli.add({}, *files) # Get all added and updated files
|
262
264
|
cli.add({ :update => true }, *files) # Get all deleted files
|
263
|
-
|
265
|
+
|
264
266
|
commit_options = {
|
265
267
|
:m => "<#{user}> #{message}",
|
266
|
-
:allow_empty => config.get(:allow_empty, false)
|
268
|
+
:allow_empty => config.get(:allow_empty, false)
|
267
269
|
}
|
268
270
|
commit_options[:author] = config[:author] if config.get(:author, false)
|
269
|
-
|
271
|
+
|
270
272
|
logger.debug("Composing commit options: #{commit_options.inspect}")
|
271
273
|
result = cli.commit(commit_options)
|
272
|
-
|
274
|
+
|
273
275
|
if result.status == code.success
|
274
276
|
new?(true)
|
275
277
|
true
|
276
278
|
else
|
277
279
|
false
|
278
280
|
end
|
279
|
-
end
|
281
|
+
end
|
280
282
|
end
|
281
283
|
|
282
284
|
#-----------------------------------------------------------------------------
|
283
285
|
# Subproject operations
|
284
|
-
|
286
|
+
|
285
287
|
def load_subprojects(options = {})
|
286
288
|
return super do |project_path, data|
|
287
289
|
File.exist?(File.join(project_path, '.git'))
|
288
290
|
end
|
289
291
|
end
|
290
|
-
|
292
|
+
|
291
293
|
#---
|
292
|
-
|
294
|
+
|
293
295
|
def add_subproject(path, url, revision, options = {})
|
294
296
|
return super do |config|
|
295
297
|
branch_options = ''
|
296
298
|
branch_options = [ '-b', config[:revision] ] if config.get(:revision, false)
|
297
|
-
|
299
|
+
|
298
300
|
path = config[:path]
|
299
301
|
url = config[:url]
|
300
|
-
|
302
|
+
|
301
303
|
result = cli.submodule({}, 'add', *branch_options, url, path)
|
302
|
-
|
304
|
+
|
303
305
|
if result.status == code.success
|
304
|
-
config.set(:files, [ '.gitmodules', path ])
|
306
|
+
config.set(:files, [ '.gitmodules', path ])
|
305
307
|
true
|
306
308
|
else
|
307
309
|
false
|
308
310
|
end
|
309
|
-
end
|
311
|
+
end
|
310
312
|
end
|
311
|
-
|
313
|
+
|
312
314
|
#---
|
313
|
-
|
315
|
+
|
314
316
|
def delete_subproject(path)
|
315
317
|
return super do |config|
|
316
318
|
path = config[:path]
|
317
319
|
submodule_key = "submodule.#{path}"
|
318
|
-
|
320
|
+
|
319
321
|
logger.debug("Deleting Git configurations for #{submodule_key}")
|
320
322
|
delete_config(submodule_key)
|
321
323
|
delete_config(submodule_key, { :file => '.gitmodules' })
|
322
|
-
|
324
|
+
|
323
325
|
logger.debug("Cleaning Git index cache for #{path}")
|
324
326
|
cli.rm({ :cached => true }, path)
|
325
|
-
|
327
|
+
|
326
328
|
logger.debug("Removing Git submodule directories")
|
327
329
|
FileUtils.rm_rf(File.join(directory, path))
|
328
330
|
FileUtils.rm_rf(File.join(repo.path, 'modules', path))
|
329
|
-
|
331
|
+
|
330
332
|
config.set(:files, [ '.gitmodules', path ])
|
331
|
-
end
|
333
|
+
end
|
332
334
|
end
|
333
|
-
|
335
|
+
|
334
336
|
#---
|
335
|
-
|
337
|
+
|
336
338
|
def update_subprojects(options = {})
|
337
339
|
return super do |config|
|
338
340
|
result = cli.submodule({}, 'update', '--init', '--recursive')
|
339
341
|
result.status == code.success
|
340
342
|
end
|
341
343
|
end
|
342
|
-
|
344
|
+
|
343
345
|
#-----------------------------------------------------------------------------
|
344
346
|
# Remote operations
|
345
|
-
|
347
|
+
|
346
348
|
def init_remotes
|
347
349
|
return super do
|
348
350
|
origin_url = config('remote.origin.url')
|
349
|
-
|
351
|
+
|
350
352
|
logger.debug("Original origin remote url: #{origin_url}") if origin_url
|
351
353
|
origin_url
|
352
354
|
end
|
353
355
|
end
|
354
|
-
|
356
|
+
|
355
357
|
#---
|
356
|
-
|
358
|
+
|
357
359
|
def remote(name)
|
358
360
|
return super do
|
359
361
|
url = config("remote.#{name}.url")
|
360
362
|
url.nil? || url.empty? ? nil : url
|
361
363
|
end
|
362
364
|
end
|
363
|
-
|
365
|
+
|
364
366
|
#---
|
365
|
-
|
367
|
+
|
366
368
|
def set_remote(name, url)
|
367
369
|
return super do |processed_url|
|
368
370
|
result = cli.remote({}, 'add', name, processed_url)
|
369
371
|
result.status == code.success
|
370
372
|
end
|
371
373
|
end
|
372
|
-
|
374
|
+
|
373
375
|
#---
|
374
|
-
|
376
|
+
|
375
377
|
def add_remote_url(name, url, options = {})
|
376
378
|
return super do |config, processed_url|
|
377
379
|
result = cli.remote({
|
@@ -382,152 +384,152 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
382
384
|
result.status == code.success
|
383
385
|
end
|
384
386
|
end
|
385
|
-
|
387
|
+
|
386
388
|
#---
|
387
|
-
|
389
|
+
|
388
390
|
def delete_remote(name)
|
389
391
|
return super do
|
390
392
|
remote = remote(name)
|
391
393
|
if ! remote || remote.empty?
|
392
394
|
logger.debug("Project can not delete remote #{name} because it does not exist yet")
|
393
|
-
true
|
395
|
+
true
|
394
396
|
else
|
395
397
|
result = cli.remote({}, 'rm', name)
|
396
398
|
result.status == code.success
|
397
399
|
end
|
398
400
|
end
|
399
401
|
end
|
400
|
-
|
402
|
+
|
401
403
|
#---
|
402
|
-
|
404
|
+
|
403
405
|
def synchronize(cloud, options = {})
|
404
406
|
return super do |config|
|
405
407
|
config.init(:remote_path, '/var/git')
|
406
408
|
config.set(:add, true)
|
407
409
|
end
|
408
410
|
end
|
409
|
-
|
411
|
+
|
410
412
|
#-----------------------------------------------------------------------------
|
411
413
|
# SSH operations
|
412
|
-
|
414
|
+
|
413
415
|
def git_fetch(remote = :origin, options = {}, &block)
|
414
416
|
config = Config.ensure(options)
|
415
417
|
local_revision = config.get(:revision, get(:revision, :master))
|
416
|
-
|
418
|
+
|
417
419
|
result = cli.fetch({}, remote, &block)
|
418
|
-
|
420
|
+
|
419
421
|
if result.status == code.success
|
420
422
|
new?(true)
|
421
423
|
checkout(local_revision)
|
422
424
|
else
|
423
425
|
false
|
424
|
-
end
|
426
|
+
end
|
425
427
|
end
|
426
428
|
protected :git_fetch
|
427
|
-
|
429
|
+
|
428
430
|
#---
|
429
|
-
|
431
|
+
|
430
432
|
def pull(remote = :origin, options = {}, &block)
|
431
433
|
return super do |config, processed_remote|
|
432
434
|
success = false
|
433
|
-
|
435
|
+
|
434
436
|
if new? || get(:create, false)
|
435
|
-
success = git_fetch(processed_remote, config)
|
437
|
+
success = git_fetch(processed_remote, config)
|
436
438
|
end
|
437
|
-
|
439
|
+
|
438
440
|
pull_options = {}
|
439
441
|
pull_options[:tags] = true if config.get(:tags, true)
|
440
|
-
|
442
|
+
|
441
443
|
local_revision = config.get(:revision, get(:revision, :master))
|
442
|
-
|
444
|
+
|
443
445
|
if checkout(local_revision)
|
444
446
|
result = cli.pull(pull_options, processed_remote, local_revision, &block)
|
445
|
-
|
447
|
+
|
446
448
|
if result.status == code.success
|
447
449
|
new?(true)
|
448
450
|
success = true
|
449
451
|
end
|
450
452
|
end
|
451
|
-
success
|
453
|
+
success
|
452
454
|
end
|
453
455
|
end
|
454
|
-
|
456
|
+
|
455
457
|
#---
|
456
|
-
|
458
|
+
|
457
459
|
def push(remote = :edit, options = {}, &block)
|
458
460
|
return super do |config, processed_remote|
|
459
461
|
push_branch = config.get(:revision, '')
|
460
|
-
|
462
|
+
|
461
463
|
push_options = {}
|
462
464
|
push_options[:all] = true if push_branch.empty?
|
463
465
|
push_options[:tags] = true if ! push_branch.empty? && config.get(:tags, true)
|
464
|
-
|
465
|
-
result = cli.push(push_options, processed_remote, push_branch, &block)
|
466
|
+
|
467
|
+
result = cli.push(push_options, processed_remote, push_branch, &block)
|
466
468
|
result.status == code.success
|
467
469
|
end
|
468
470
|
end
|
469
|
-
|
471
|
+
|
470
472
|
#-----------------------------------------------------------------------------
|
471
473
|
# Utilities
|
472
|
-
|
474
|
+
|
473
475
|
def translate_url(host, path, options = {})
|
474
476
|
return super do |config|
|
475
477
|
user = config.get(:user, 'git')
|
476
478
|
auth = config.get(:auth, true)
|
477
|
-
|
479
|
+
|
478
480
|
user + (auth ? '@' : '://') + host + (auth ? ':' : '/') + path
|
479
481
|
end
|
480
482
|
end
|
481
|
-
|
483
|
+
|
482
484
|
#---
|
483
|
-
|
485
|
+
|
484
486
|
def translate_edit_url(url, options = {})
|
485
|
-
return super do |config|
|
487
|
+
return super do |config|
|
486
488
|
if matches = url.strip.match(/^(https?|git)\:\/\/([^\/]+)\/(.+)/)
|
487
489
|
protocol, host, path = matches.captures
|
488
490
|
translate_url(host, path, config.import({ :auth => true }))
|
489
491
|
end
|
490
492
|
end
|
491
493
|
end
|
492
|
-
|
494
|
+
|
493
495
|
#---
|
494
|
-
|
496
|
+
|
495
497
|
def git_exec(command, options = {}, args = [])
|
496
498
|
result = nil
|
497
|
-
|
499
|
+
|
498
500
|
if can_persist?
|
499
501
|
check_value = lambda do |value|
|
500
502
|
next false if value.nil?
|
501
503
|
next false unless value.is_a?(String) || value.is_a?(Symbol)
|
502
504
|
next false if value.to_s.empty?
|
503
|
-
true
|
505
|
+
true
|
504
506
|
end
|
505
|
-
|
507
|
+
|
506
508
|
localize(repo.workdir) do
|
507
509
|
flags = []
|
508
510
|
data = {}
|
509
511
|
processed_args = []
|
510
|
-
|
512
|
+
|
511
513
|
options.each do |key, value|
|
512
514
|
cli_option = key.to_s.gsub('_', '-')
|
513
|
-
|
514
|
-
if value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
515
|
+
|
516
|
+
if value.is_a?(TrueClass) || value.is_a?(FalseClass)
|
515
517
|
flags << cli_option if value == true
|
516
|
-
|
518
|
+
|
517
519
|
elsif check_value.call(value)
|
518
520
|
data[cli_option] = value.to_s
|
519
521
|
end
|
520
522
|
end
|
521
|
-
|
523
|
+
|
522
524
|
args.each do |value|
|
523
525
|
if check_value.call(value)
|
524
526
|
processed_args << value.to_s
|
525
527
|
end
|
526
528
|
end
|
527
|
-
|
529
|
+
|
528
530
|
command_provider = get(:command_provider, Nucleon.type_default(:nucleon, :command))
|
529
|
-
quiet = get(:quiet, true)
|
530
|
-
|
531
|
+
quiet = get(:quiet, true)
|
532
|
+
|
531
533
|
command = Nucleon.command({
|
532
534
|
:command => :git,
|
533
535
|
:data => { 'git-dir=' => repo.path },
|
@@ -538,7 +540,7 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
538
540
|
:args => processed_args
|
539
541
|
}
|
540
542
|
}, command_provider)
|
541
|
-
|
543
|
+
|
542
544
|
result = command.exec({ :quiet => quiet }) do |op, cli_command, cli_data|
|
543
545
|
block_given? ? yield(op, cli_command, cli_data) : true
|
544
546
|
end
|
@@ -548,32 +550,48 @@ class Git < Nucleon.plugin_class(:nucleon, :project)
|
|
548
550
|
result
|
549
551
|
end
|
550
552
|
protected :git_exec
|
551
|
-
|
553
|
+
|
552
554
|
#---
|
553
|
-
|
555
|
+
|
554
556
|
def ensure_in_gitignore(files)
|
555
557
|
files = [ files ] unless files.is_a?(Array)
|
556
558
|
commit_files = nil
|
557
559
|
changes = false
|
558
|
-
|
560
|
+
|
559
561
|
gitignore_file = File.join(directory, '.gitignore')
|
560
562
|
ignore_raw = Util::Disk.read(gitignore_file)
|
561
563
|
ignores = []
|
562
|
-
|
563
|
-
|
564
|
+
search = []
|
565
|
+
|
566
|
+
if ignore_raw && ! ignore_raw.empty?
|
567
|
+
ignores = ignore_raw.split("\n")
|
568
|
+
search = ignores.collect do |line|
|
569
|
+
line = line.strip
|
570
|
+
( ! line.empty? && line[0] != '#' ? line : nil )
|
571
|
+
end.compact
|
572
|
+
end
|
573
|
+
|
564
574
|
files.each do |file|
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
575
|
+
if @ignore_cache[file]
|
576
|
+
found = true
|
577
|
+
else
|
578
|
+
file_regex = Regexp.escape(file)
|
579
|
+
found = false
|
580
|
+
unless search.empty?
|
581
|
+
search.each do |ignore|
|
582
|
+
if ignore.strip.match(/^#{file_regex}\/?$/)
|
583
|
+
found = true
|
584
|
+
@ignore_cache[file] = true
|
585
|
+
break
|
586
|
+
end
|
587
|
+
end
|
571
588
|
end
|
572
589
|
end
|
573
590
|
unless found
|
574
591
|
ignores << file
|
575
|
-
changes
|
576
|
-
|
592
|
+
changes = true
|
593
|
+
@ignore_cache[file] = true
|
594
|
+
end
|
577
595
|
end
|
578
596
|
if changes
|
579
597
|
Util::Disk.write(gitignore_file, ignores.join("\n"))
|
data/nucleon.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: nucleon 0.2.
|
5
|
+
# stub: nucleon 0.2.6 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "nucleon"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.6"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Adrian Webb"]
|
14
|
-
s.date = "2015-01-
|
14
|
+
s.date = "2015-01-18"
|
15
15
|
s.description = "\nA framework that provides a simple foundation for building Ruby applications that are:\n\n* Highly configurable (with both distributed and persistent configurations)\n* Extremely pluggable and extendable\n* Easily parallel\n\nNote: This framework is still very early in development!\n"
|
16
16
|
s.email = "adrian.webb@coralnexus.com"
|
17
17
|
s.executables = ["nucleon"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nucleon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Webb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: log4r
|