confgit 0.0.3 → 0.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.
- data/VERSION +1 -1
- data/etc/tools/update_version.rb +3 -1
- data/lib/confgit/cli.rb +2 -3
- data/lib/confgit/repo.rb +15 -10
- data/lib/confgit/version.rb +1 -1
- data/lib/confgit/with_color.rb +1 -1
- data/spec/confgit_spec.rb +79 -25
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/etc/tools/update_version.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
def update_version(path)
|
2
|
-
version = `git describe --
|
2
|
+
version = `git describe --dirty 2>/dev/null`.chomp
|
3
|
+
version = `git describe --tags --dirty`.chomp if version.empty?
|
4
|
+
version[0, 1] = '' if version =~ /^v[0-9]/
|
3
5
|
version.gsub!(/-([a-z0-9]+(-dirty)?)$/) { |m| "(#{$1})" }
|
4
6
|
|
5
7
|
begin
|
data/lib/confgit/cli.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
3
2
|
|
4
3
|
require 'optparse'
|
5
4
|
require 'rubygems'
|
@@ -83,7 +82,7 @@ class CLI
|
|
83
82
|
OptionParser.new { |opts|
|
84
83
|
begin
|
85
84
|
opts.banner = banner(opts, command, *banner)
|
86
|
-
|
85
|
+
instance_exec(opts, argv, options, &block)
|
87
86
|
rescue => e
|
88
87
|
abort e.to_s
|
89
88
|
end
|
data/lib/confgit/repo.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'pathname'
|
@@ -281,10 +281,13 @@ class Repo
|
|
281
281
|
File.unlink(to)
|
282
282
|
end
|
283
283
|
|
284
|
-
FileUtils.
|
284
|
+
FileUtils.copy_entry(from, to)
|
285
285
|
stat = File.stat(from)
|
286
|
-
|
287
|
-
File.
|
286
|
+
|
287
|
+
unless File.symlink?(to)
|
288
|
+
File.utime(stat.atime, stat.mtime, to)
|
289
|
+
File.chmod(stat.mode, to)
|
290
|
+
end
|
288
291
|
|
289
292
|
return true
|
290
293
|
rescue => e
|
@@ -478,23 +481,25 @@ class Repo
|
|
478
481
|
next
|
479
482
|
end
|
480
483
|
|
481
|
-
if File.directory?(path)
|
484
|
+
if File.directory?(path) && ! File.symlink?(path)
|
482
485
|
dir_each(path) { |file|
|
483
486
|
next if File.directory?(file)
|
484
487
|
|
485
488
|
from = File.join(path, file)
|
486
|
-
|
489
|
+
rel = relative_path(from)
|
490
|
+
to = File.join(repo, rel)
|
487
491
|
|
488
492
|
if filecopy(from, to)
|
489
|
-
git('add',
|
493
|
+
git('add', rel)
|
490
494
|
end
|
491
495
|
}
|
492
496
|
else
|
493
497
|
from = path
|
494
|
-
|
498
|
+
rel = relative_path(from)
|
499
|
+
to = File.join(repo, rel)
|
495
500
|
|
496
501
|
if filecopy(from, to)
|
497
|
-
git('add',
|
502
|
+
git('add', rel)
|
498
503
|
end
|
499
504
|
end
|
500
505
|
}
|
@@ -508,7 +513,7 @@ class Repo
|
|
508
513
|
repo = File.realpath(@repo_path)
|
509
514
|
|
510
515
|
files = args.collect { |from|
|
511
|
-
|
516
|
+
relative_path(expand_path(from))
|
512
517
|
}
|
513
518
|
|
514
519
|
git('rm', *(options + files), :interactive => false)
|
data/lib/confgit/version.rb
CHANGED
data/lib/confgit/with_color.rb
CHANGED
data/spec/confgit_spec.rb
CHANGED
@@ -1,10 +1,24 @@
|
|
1
|
-
#
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require File.expand_path('../spec_helper', __FILE__)
|
4
4
|
require 'confgit'
|
5
5
|
|
6
6
|
|
7
7
|
describe Confgit do
|
8
|
+
class String
|
9
|
+
# 1行目のインデントだけ全体のインデントを削除する
|
10
|
+
def cut_indent(prefix = '')
|
11
|
+
prefix = Regexp.escape(prefix)
|
12
|
+
|
13
|
+
if self =~ /^(\s+#{prefix})/
|
14
|
+
indent = Regexp.escape($1)
|
15
|
+
self.gsub(/^#{indent}/,'')
|
16
|
+
else
|
17
|
+
self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
8
22
|
# 引数の最後が Hash ならオプションとして取出す
|
9
23
|
def arg_last_options(args)
|
10
24
|
if args.last && args.last.kind_of?(Hash)
|
@@ -77,7 +91,7 @@ describe Confgit do
|
|
77
91
|
proc {
|
78
92
|
confgit 'repo', name
|
79
93
|
confgit 'repo'
|
80
|
-
}.must_output <<-EOD.
|
94
|
+
}.must_output <<-EOD.cut_indent
|
81
95
|
* #{name}
|
82
96
|
#{@hostname}
|
83
97
|
EOD
|
@@ -91,7 +105,7 @@ describe Confgit do
|
|
91
105
|
confgit 'repo', name2
|
92
106
|
confgit 'repo', '-d', name1
|
93
107
|
confgit 'repo'
|
94
|
-
}.must_output <<-EOD.
|
108
|
+
}.must_output <<-EOD.cut_indent
|
95
109
|
* #{name2}
|
96
110
|
#{@hostname}
|
97
111
|
EOD
|
@@ -104,7 +118,7 @@ describe Confgit do
|
|
104
118
|
confgit 'repo', '-d', name
|
105
119
|
@abort == "'#{name}' is current repository!\n"
|
106
120
|
confgit 'repo'
|
107
|
-
}.must_output <<-EOD.
|
121
|
+
}.must_output <<-EOD.cut_indent
|
108
122
|
* #{name}
|
109
123
|
#{@hostname}
|
110
124
|
EOD
|
@@ -145,7 +159,7 @@ describe Confgit do
|
|
145
159
|
it "add FILE" do
|
146
160
|
chroot('README') { |root, file|
|
147
161
|
confgit 'add', file
|
148
|
-
proc { confgit 'status' }.must_output <<-EOD.
|
162
|
+
proc { confgit 'status' }.must_output <<-EOD.cut_indent
|
149
163
|
# On branch master
|
150
164
|
#
|
151
165
|
# Initial commit
|
@@ -164,7 +178,7 @@ describe Confgit do
|
|
164
178
|
|
165
179
|
chroot(File.join(dir, 'README')) { |root, file|
|
166
180
|
confgit 'add', dir
|
167
|
-
proc { confgit 'status' }.must_output <<-EOD.
|
181
|
+
proc { confgit 'status' }.must_output <<-EOD.cut_indent
|
168
182
|
# On branch master
|
169
183
|
#
|
170
184
|
# Initial commit
|
@@ -177,6 +191,27 @@ describe Confgit do
|
|
177
191
|
EOD
|
178
192
|
}
|
179
193
|
end
|
194
|
+
|
195
|
+
it "add SYMLINK" do
|
196
|
+
dir = 'misc'
|
197
|
+
dummy = 'misc_symlink'
|
198
|
+
|
199
|
+
chroot(File.join(dir, 'README')) { |root, file|
|
200
|
+
File.symlink(dir, dummy)
|
201
|
+
confgit 'add', dummy
|
202
|
+
proc { confgit 'status' }.must_output <<-EOD.cut_indent
|
203
|
+
# On branch master
|
204
|
+
#
|
205
|
+
# Initial commit
|
206
|
+
#
|
207
|
+
# Changes to be committed:
|
208
|
+
# (use "git rm --cached <file>..." to unstage)
|
209
|
+
#
|
210
|
+
# new file: #{dummy}
|
211
|
+
#
|
212
|
+
EOD
|
213
|
+
}
|
214
|
+
end
|
180
215
|
end
|
181
216
|
|
182
217
|
describe "rm" do
|
@@ -186,7 +221,7 @@ describe Confgit do
|
|
186
221
|
|
187
222
|
capture_io { confgit 'commit', '-m', "add #{file}" }
|
188
223
|
proc { confgit 'rm', file }.must_output "rm '#{file}'\n"
|
189
|
-
proc { confgit 'status' }.must_output <<-EOD.
|
224
|
+
proc { confgit 'status' }.must_output <<-EOD.cut_indent
|
190
225
|
# On branch master
|
191
226
|
# Changes to be committed:
|
192
227
|
# (use "git reset HEAD <file>..." to unstage)
|
@@ -202,7 +237,7 @@ describe Confgit do
|
|
202
237
|
confgit 'add', file
|
203
238
|
|
204
239
|
proc { confgit 'rm', '-f', file }.must_output "rm '#{file}'\n"
|
205
|
-
proc { confgit 'status' }.must_output <<-EOD.
|
240
|
+
proc { confgit 'status' }.must_output <<-EOD.cut_indent
|
206
241
|
# On branch master
|
207
242
|
#
|
208
243
|
# Initial commit
|
@@ -220,7 +255,7 @@ describe Confgit do
|
|
220
255
|
|
221
256
|
capture_io { confgit 'commit', '-m', "add #{dir}" }
|
222
257
|
proc { confgit 'rm', '-r', dir }.must_output "rm '#{file}'\n"
|
223
|
-
proc { confgit 'status' }.must_output <<-EOD.
|
258
|
+
proc { confgit 'status' }.must_output <<-EOD.cut_indent
|
224
259
|
# On branch master
|
225
260
|
# Changes to be committed:
|
226
261
|
# (use "git reset HEAD <file>..." to unstage)
|
@@ -238,7 +273,26 @@ describe Confgit do
|
|
238
273
|
confgit 'add', dir
|
239
274
|
|
240
275
|
proc { confgit 'rm', '-rf', dir }.must_output "rm '#{file}'\n"
|
241
|
-
proc { confgit 'status' }.must_output <<-EOD.
|
276
|
+
proc { confgit 'status' }.must_output <<-EOD.cut_indent
|
277
|
+
# On branch master
|
278
|
+
#
|
279
|
+
# Initial commit
|
280
|
+
#
|
281
|
+
nothing to commit (create/copy files and use "git add" to track)
|
282
|
+
EOD
|
283
|
+
}
|
284
|
+
end
|
285
|
+
|
286
|
+
it "rm -f SYMLINK" do
|
287
|
+
dir = 'misc'
|
288
|
+
dummy = 'misc_symlink'
|
289
|
+
|
290
|
+
chroot(File.join(dir, 'README')) { |root, file|
|
291
|
+
File.symlink(dir, dummy)
|
292
|
+
confgit 'add', dummy
|
293
|
+
|
294
|
+
proc { confgit 'rm', '-f', dummy }.must_output "rm '#{dummy}'\n"
|
295
|
+
proc { confgit 'status' }.must_output <<-EOD.cut_indent
|
242
296
|
# On branch master
|
243
297
|
#
|
244
298
|
# Initial commit
|
@@ -263,7 +317,7 @@ describe Confgit do
|
|
263
317
|
|
264
318
|
it "backup -n" do
|
265
319
|
chroot { |root, *files|
|
266
|
-
proc { confgit 'backup', '-n' }.must_output <<-EOD.
|
320
|
+
proc { confgit 'backup', '-n' }.must_output <<-EOD.cut_indent
|
267
321
|
\e[34m--> #{@mod_file}\e[m
|
268
322
|
# On branch master
|
269
323
|
nothing to commit (working directory clean)
|
@@ -273,7 +327,7 @@ describe Confgit do
|
|
273
327
|
|
274
328
|
it "backup -y" do
|
275
329
|
chroot { |root, *files|
|
276
|
-
proc { confgit 'backup', '-y' }.must_output <<-EOD.
|
330
|
+
proc { confgit 'backup', '-y' }.must_output <<-EOD.cut_indent
|
277
331
|
\e[34m--> VERSION\e[m
|
278
332
|
# On branch master
|
279
333
|
# Changes not staged for commit:
|
@@ -291,7 +345,7 @@ describe Confgit do
|
|
291
345
|
chroot { |root, *files|
|
292
346
|
File.delete @mod_file
|
293
347
|
|
294
|
-
proc { confgit 'backup', '-fn' }.must_output <<-EOD.
|
348
|
+
proc { confgit 'backup', '-fn' }.must_output <<-EOD.cut_indent
|
295
349
|
\e[34m--> LICENSE.txt\e[m
|
296
350
|
\e[34m--> README\e[m
|
297
351
|
\e[31m[?] #{@mod_file}\e[m
|
@@ -318,7 +372,7 @@ describe Confgit do
|
|
318
372
|
open(@mod_file, 'w') { |f| f.puts @data }
|
319
373
|
|
320
374
|
modfile(@mod_file) { |prev|
|
321
|
-
proc { confgit 'restore', '-n' }.must_output <<-EOD.
|
375
|
+
proc { confgit 'restore', '-n' }.must_output <<-EOD.cut_indent
|
322
376
|
\e[34m<-- #{@mod_file}\e[m
|
323
377
|
EOD
|
324
378
|
open(@mod_file).read.must_equal prev
|
@@ -331,7 +385,7 @@ describe Confgit do
|
|
331
385
|
modfile(@mod_file) { |prev|
|
332
386
|
open(@mod_file, 'w') { |f| f.puts @data }
|
333
387
|
|
334
|
-
proc { confgit 'restore', '-y' }.must_output <<-EOD.
|
388
|
+
proc { confgit 'restore', '-y' }.must_output <<-EOD.cut_indent
|
335
389
|
\e[34m<-- #{@mod_file}\e[m
|
336
390
|
EOD
|
337
391
|
open(@mod_file).read.must_equal prev
|
@@ -343,7 +397,7 @@ describe Confgit do
|
|
343
397
|
chroot { |root, *files|
|
344
398
|
File.delete @mod_file
|
345
399
|
|
346
|
-
proc { confgit 'restore', '-fn' }.must_output <<-EOD.
|
400
|
+
proc { confgit 'restore', '-fn' }.must_output <<-EOD.cut_indent
|
347
401
|
\e[34m<-- LICENSE.txt\e[m
|
348
402
|
\e[34m<-- README\e[m
|
349
403
|
\e[35m<-- #{@mod_file}\e[m
|
@@ -359,10 +413,10 @@ describe Confgit do
|
|
359
413
|
out, err, status = capture_io { confgit 'commit', '-m', "add #{file}" }
|
360
414
|
err.must_be_empty
|
361
415
|
status.must_be_nil
|
362
|
-
out.must_match <<-EOD.
|
363
|
-
|
364
|
-
|
365
|
-
|
416
|
+
out.must_match <<-EOD.cut_indent('|')
|
417
|
+
|
|
418
|
+
| 0 files changed
|
419
|
+
| create mode 100644 #{file}
|
366
420
|
EOD
|
367
421
|
}
|
368
422
|
end
|
@@ -379,7 +433,7 @@ describe Confgit do
|
|
379
433
|
it "list" do
|
380
434
|
chroot { |root, *files|
|
381
435
|
out, err, status = capture_io { confgit 'list' }
|
382
|
-
out.must_match Regexp.new <<-EOD.
|
436
|
+
out.must_match Regexp.new <<-EOD.cut_indent
|
383
437
|
-rw-r--r-- .+ .+ #{root}/LICENSE\.txt
|
384
438
|
-rw-r--r-- .+ .+ #{root}/README
|
385
439
|
-rw-r--r-- .+ .+ #{root}/VERSION
|
@@ -390,7 +444,7 @@ describe Confgit do
|
|
390
444
|
it "list -8" do
|
391
445
|
chroot { |root, *files|
|
392
446
|
out, err, status = capture_io { confgit 'list', '-8' }
|
393
|
-
out.must_match Regexp.new <<-EOD.
|
447
|
+
out.must_match Regexp.new <<-EOD.cut_indent
|
394
448
|
100644 .+ .+ #{root}/LICENSE\.txt
|
395
449
|
100644 .+ .+ #{root}/README
|
396
450
|
100644 .+ .+ #{root}/VERSION
|
@@ -409,7 +463,7 @@ describe Confgit do
|
|
409
463
|
|
410
464
|
it "tree" do
|
411
465
|
chroot { |root, *files|
|
412
|
-
proc { confgit 'tree' }.must_output <<-EOD.
|
466
|
+
proc { confgit 'tree' }.must_output <<-EOD.cut_indent
|
413
467
|
.
|
414
468
|
├── README
|
415
469
|
├── VERSION
|
@@ -423,7 +477,7 @@ describe Confgit do
|
|
423
477
|
|
424
478
|
it "tree -a" do
|
425
479
|
chroot { |root, *files|
|
426
|
-
proc { confgit 'tree', '-a' }.must_output <<-EOD.
|
480
|
+
proc { confgit 'tree', '-a' }.must_output <<-EOD.cut_indent
|
427
481
|
.
|
428
482
|
├── .version
|
429
483
|
├── README
|
@@ -438,7 +492,7 @@ describe Confgit do
|
|
438
492
|
|
439
493
|
it "tree DIR" do
|
440
494
|
chroot { |root, *files|
|
441
|
-
proc { confgit 'tree', @dir }.must_output <<-EOD.
|
495
|
+
proc { confgit 'tree', @dir }.must_output <<-EOD.cut_indent
|
442
496
|
#{@dir}
|
443
497
|
└── LICENSE.txt
|
444
498
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -106,7 +106,7 @@ homepage: https://github.com/gnue/confgit
|
|
106
106
|
licenses: []
|
107
107
|
post_install_message: ! "\n ==================\n This software requires 'git'.\n
|
108
108
|
\ Also optional softwares 'tree' and 'tig'.\n\n If you are using the bash-completion\n\n
|
109
|
-
\ $ cp `gem env gemdir`/gems/confgit-0.0.
|
109
|
+
\ $ cp `gem env gemdir`/gems/confgit-0.0.4/etc/bash_completion.d/confgit $BASH_COMPLETION_DIR\n\n
|
110
110
|
\ ==================\n "
|
111
111
|
rdoc_options: []
|
112
112
|
require_paths:
|